MySQL-5.6.29源码编译安装记录

一、安装环境

1. 操作系统:CentOS 6.7 x86_64

# yum install make cmake gcc gcc-c++ gcc-g77 flex bison file libtool libtool-libs autoconf kernel-devel patch wget libjpeg libjpeg-devel libpng libpng-devel libpng10 libpng10-devel gd gd-devel libxml2 libxml2-devel zlib zlib-devel glib2 glib2-devel unzip tar bzip2 bzip2-devel libevent libevent-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel vim-minimal gettext gettext-devel ncurses-devel gmp-devel pspell-devel unzip libcap diffutils net-tools libc-client-devel psmisc libXpm-devel git-core c-ares-devel perl  
2. cmake采用yum方式已安装,不需要再安装。

3. MySQL版本:mysql-5.6.29.tar.gz

4. 同样安装方式也适用于mysql-5.5.x.tar.gz

二、安装mysql-5.6.29.tar.gz

1. 下载编译版本mysql安装

tar zxvf mysql-5.6.29.tar.gz  
cd mysql-5.6.29    
patch -p1 < ../mysql-openssl.patch    
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/usr/local/mysql/data -DSYSCONFDIR=/etc -DMYSQL_UNIX_ADDR=/tmp/mysql.sock -DEXTRA_CHARSETS=gbk,gb2312,utf8,ascii -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_READLINE=1 -DWITH_SSL=system -DWITH_ZLIB=system -DWITH_EMBEDDED_SERVER=1 -DENABLED_LOCAL_INFILE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_FEDERATED_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DWITH_PERFSCHEMA_STORAGE_ENGINE=1 -DWITH_FAST_MUTEXES=1 -DWITH_DEBUG=0    
make && make install

注:重新编驻译采用如下方式,ssl方式不需要采用,可以删除掉相关参数。
make clean    
rm -f CMakeCache.txt

2. 准备mysql用户

groupadd mysql  
useradd -g mysql -M -s /sbin/nologin mysql

3. 初始化mysql,数据库位置采用默认位置

chown -R mysql:mysql /usr/local/mysql  
/usr/local/mysql/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data

4. mysql服务配置

cd /usr/local/mysql  
cp support-files/my-medium.cnf /etc/my.cnf    
cp support-files/mysql.server  /etc/rc.d/init.d/mysqld    
chkconfig --add mysqld    
chkconfig mysqld on

5. 配置Mysql命令链接

ln -sf /usr/local/mysql/bin/mysql /usr/bin/mysql  
ln -sf /usr/local/mysql/bin/mysqldump /usr/bin/mysqldump    
ln -sf /usr/local/mysql/bin/myisamchk /usr/bin/myisamchk    
ln -sf /usr/local/mysql/bin/mysqld_safe /usr/bin/mysqld_safe

或通过加入环境变量中解决。

# vi /etc/profile    
export PATH=/usr/local/mysql/bin/:$PATH    
# source /etc/profile

6. 配置其它

ln -sv /usr/local/mysql/include  /usr/include/mysql    
echo ‘/usr/local/mysql/lib‘ > /etc/ld.so.conf.d/mysql.conf    
ldconfig

7. Mysql配置文件

vi /etc/my.cnf

[client]  
port        = 3306    
socket      = /tmp/mysql.sock

# The MySQL server  
[mysqld]    
port        = 3306    
socket      = /tmp/mysql.sock    
datadir = /usr/local/mysql/data    
skip-external-locking    
max_connections = 1000    
key_buffer_size = 16M    
max_allowed_packet = 1M    
table_open_cache = 64    
sort_buffer_size = 512K    
net_buffer_length = 8K    
read_buffer_size = 256K    
read_rnd_buffer_size = 512K    
myisam_sort_buffer_size = 8M

#skip-networking

log-bin=mysql-bin  
binlog_format=mixed    
server-id   = 1

innodb_data_home_dir = /usr/local/mysql/data  
innodb_data_file_path = ibdata1:10M:autoextend    
innodb_log_group_home_dir = /usr/local/mysql/data    
innodb_buffer_pool_size = 16M    
innodb_additional_mem_pool_size = 2M    
innodb_log_file_size = 5M    
innodb_log_buffer_size = 8M    
innodb_flush_log_at_trx_commit = 1    
innodb_lock_wait_timeout = 50

[mysqldump]  
quick    
max_allowed_packet = 16M

[mysql]  
no-auto-rehash

[myisamchk]  
key_buffer_size = 20M    
sort_buffer_size = 20M    
read_buffer = 2M    
write_buffer = 2M

[mysqlhotcopy]  
interactive-timeout    
expire_logs_days = 10

8. 启动mysql

service mysqld start

9. 修改管理员密码并测试

# /usr/local/mysql/bin/mysqladmin -u root password ‘admin‘ #设置管理员密码  
# /usr/local/mysql/bin/mysql -u root -p   #测试密码输入

10. 配置mysql帐号安全

[[email protected] ~]# /usr/local/mysql/bin/mysql_secure_installation

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL  
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MySQL to secure it, we‘ll need the current  
password for the root user.  If you‘ve just installed MySQL, and    
you haven‘t set the root password yet, the password will be blank,    
so you should just press enter here.

Enter current password for root (enter for none):    
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MySQL  
root user without the proper authorisation.

You already have a root password set, so you can safely answer ‘n‘.

Change the root password? [Y/n] n  
... skipping.

By default, a MySQL installation has an anonymous user, allowing anyone  
to log into MySQL without having to have a user account created for    
them.  This is intended only for testing, and to make the installation    
go a bit smoother.  You should remove them before moving into a    
production environment.

Remove anonymous users? [Y/n] y  
... Success!

Normally, root should only be allowed to connect from ‘localhost‘.  This  
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] n  
... skipping.

By default, MySQL comes with a database named ‘test‘ that anyone can  
access.  This is also intended only for testing, and should be removed    
before moving into a production environment.

Remove test database and access to it? [Y/n] y  
- Dropping test database...    
... Success!    
- Removing privileges on test database...    
... Success!

Reloading the privilege tables will ensure that all changes made so far  
will take effect immediately.

Reload privilege tables now? [Y/n] y  
... Success!

All done!  If you‘ve completed all of the above steps, your MySQL  
installation should now be secure.

Thanks for using MySQL!

Cleaning up...

登录测试:

[[email protected] data]# mysql -uroot -p  
Enter password:    
Welcome to the MySQL monitor.  Commands end with ; or \g.    
Your MySQL connection id is 9    
Server version: 5.6.29-log Source distribution

Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its  
affiliates. Other names may be trademarks of their respective    
owners.

Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement.

mysql> \s  
--------------    
mysql  Ver 14.14 Distrib 5.6.29, for Linux (x86_64) using  EditLine wrapper

Connection id:          9  
Current database:    
Current user:           [email protected]    
SSL:                    Not in use    
Current pager:          stdout    
Using outfile:          ‘‘    
Using delimiter:        ;    
Server version:         5.6.29-log Source distribution    
Protocol version:       10    
Connection:             Localhost via UNIX socket    
Server characterset:    utf8    
Db     characterset:    utf8    
Client characterset:    utf8    
Conn.  characterset:    utf8    
UNIX socket:            /tmp/mysql.sock    
Uptime:                 9 min 36 sec

Threads: 1  Questions: 29  Slow queries: 0  Opens: 71  Flush tables: 1  Open tables: 64  Queries per second avg: 0.050  
--------------

mysql>

安装完毕。

时间: 2024-08-11 05:44:28

MySQL-5.6.29源码编译安装记录的相关文章

lnmp环境源码编译安装记录

系统:Cenos 6.5 X64 软件: tengine-2.0.3.tar.gz pcre-8.33.tar.bz2 mysql-5.6.12.tar.gz php-5.5.14.tar.bz2 一.安装nginx 1.1 安装nginx所需的pcre-devel库,使nginx支持HTTP Rewrite模块 [[email protected]]# ./configure --prefix=/home/webserver/pcre  && make && make i

mysql5.7.10 源码编译安装记录 (centos6.4)【转】

一.准备工作 1.1 卸载系统自带mysql 查看系统是否自带MySQL, 如果有就卸载了, 卸载方式有两种yum, rpm, 这里通过yum卸载 rpm -qa | grep mysql //查看系统自带mysql yum -y remove mysql-* //卸载mysql rpm -e --nodeps mysql-5.1.73-3.el6_5.x86_64 //卸载mysql 1.2 卸载系统自带boost,并安装boost_1_59_0 mysql 5.7 依赖于boost_1_59

MySQL 5.6.37源码编译安装

MySQL 5.6.37 编译安装 什么是数据库? 简单的说,数据库(database)就是一个存放数据的仓库,这个仓库是按照一定的数据结构(数据结构是指数据的组织形式或数据之间的联系)来组织.存储的,我们可以通过数据提供的多种方法来管理数据库里的数据. 数据库的种类 按照早起的数据库理论,比较流行的数据库模型有三种,分别为层次式数据库.网络式数据库和关系型数据库,而在当今的互联网中,最常用的数据库模型主要是两种,即关系型数据库和非关系型数据库. 什么是关系型数据库? 关系型数据库模型是把复杂的

MySQL 5.7.9源码编译安装说明

一.环境说明 1.操作系统 系统版本:RHEL 6.3 X64 操作系统安装类型:Basic 系统安装包:gcc gcc-c++ bzip2(default) bzip2-devel bzip2-libs(default) python-devel ncurses-devel bison 1)gcc gcc-c++ [[email protected] Packages]# rpm -ivh kernel-headers-2.6.32-279.el6.x86_64.rpm warning: ke

MySQL 源码编译安装

脚本须知: 1. 该脚本目前只测试过mysql版本为5.6.x的源码,其他源码可以对本脚本稍作修改即可 2. 本脚本也可以使用wget mysql源码的方式进行,但考虑到后期提供源码的地址不可用,所以需要手动下载mysql 5.6.x的源码包并放入到/usr/local/src 3. 此脚本在编译安装过程中禁用了iptables和SElinux策略,如果你在使用iptalbes相关功能请先完成相关配置. 4. 该脚本主要是对此前尚未装过mysql的linux系统环境而写的,如果此前装过mysql

mysql-5.7.23源码编译安装

mysql-5.7.23源码编译安装 1.下载源码 # wget https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-5.7.23.tar.gz # tar xf mysql-5.7.23.tar.gz 2.隐藏版本信息 隐藏版本信息是XX电信运营商提出的变态要求,经测试版本信息不能直接删除,否则编译出错,暂时修改为100.100.100 # cd mysql-5.7.23 # vim VERSION MYSQL_VERSION_MAJOR=100

纯源码编译安装LAMP,linux,httpd,php,mysql源码编译安装

教程目标:使用源码编译安装的LAMP,运行php网页基础代码 日    期:2015年08月19日 联系邮箱:[email protected] Q Q  群:1851 15701 51CTO博客首页:http://990487026.blog.51cto.com做一个对读者负责的博主.安装一个和我一样的纯净系统,我可以安装成功,你也可以安装成功.我行,你也行!================================================================安装准备

linux学习笔记——源码编译安装Mysql

#######Redhat6.5源码编译安装Mysql########实验环境:1.IP:172.25.8.32.磁盘要大于20G先添加一块大于20G的磁盘fdisk /dev/vdb        ##得到/dev/vdb1 8e linuxpvcreate /dev/vdb1    ##把物理分区做成物理卷vgextend vg_server1 /dev/vdb1    ##把新建立的/dev/vdb1添加到vg_server1中lvextend -L 20G /dev/vg_server1

CentOS源码编译安装MySQL 5.5.15

CentOS源码编译安装MySQL 5.5.15 文章目录 [隐藏] 安装编译工具 下载源码 安装cmake和bison 编译安装MySQL 一些相关设置 安装编译工具 yum install gcc gcc-c++ yum install ncurses-devel 下载源码 mkdir -p /tmp cd /tmp wget http://dev.mysql.com/get/Downloads/MySQL-5.5/mysql-5.5.15.tar.gz/from/http://mysql.