centos7下源码安装mysql5.6
#安装必要源
yum -y install make bison-devel ncures-devel libaio perl-Data-Dumper net-tools bison bison-devel gcc-c++ cmake ncurses ncurses-devel
#编译,安装
[root@localhost localhost]# tar xzvf mysql-5.6.34.tar.gz
[root@localhost localhost]# cd mysql-5.6.34
[root@localhost mysql-5.6.32]# cmake \-DCMAKE_INSTALL_PREFIX=/usr/local/mysql56 -DMYSQL_DATADIR=/data/mysqldata -DSYSCONFDIR=/etc/my.cnf -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DMYSQL_UNIX_ADDR=/tmp/mysqld.sock -DMYSQL_TCP_PORT=3306 -DENABLED_LOCAL_INFILE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DEXTRA_CHARSETS=utf8 -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci
[root@localhost mysql-5.6.32]# make && make install
编译参数解释
# -DCMAKE_INSTALL_PREFIX=/usr/local/mysql56 \ #安装路径
# -DMYSQL_DATADIR=/usr/local/mysql/data \ #数据文件存放位置
# -DSYSCONFDIR=/etc \ #my.cnf路径
# -DWITH_MYISAM_STORAGE_ENGINE=1 \ #支持MyIASM引擎
# -DWITH_INNOBASE_STORAGE_ENGINE=1 \ #支持InnoDB引擎
# -DWITH_MEMORY_STORAGE_ENGINE=1 \ #支持Memory引擎
# -DWITH_READLINE=1 \ #快捷键功能(我没用过)
# -DMYSQL_UNIX_ADDR=/tmp/mysqld.sock \ #连接数据库socket路径
# -DMYSQL_TCP_PORT=3306 \ #端口
# -DENABLED_LOCAL_INFILE=1 \ #允许从本地导入数据
# -DWITH_PARTITION_STORAGE_ENGINE=1 \ #安装支持数据库分区
# -DEXTRA_CHARSETS=all \ #安装所有的字符集
# -DDEFAULT_CHARSET=utf8 \ #默认字符
# -DDEFAULT_COLLATION=utf8_general_ci
初始化
/usr/local/mysql56/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql56 --datadir=/data/mysqldata
cp support-files/my-default.cnf /etc/my.cnf
# vi /etc/my.cnf
#[mysqld] 下面添加:
user=mysql
datadir=/data/mysqldata
default-storage-engine=MyISAM
将mysql的启动服务添加到系统服务中
cp /usr/local/mysql56/support-files/mysql.server /etc/rc.d/init.d/mysqld
chkconfig --add mysqld
chkconfig --level 345 mysqld on
软链接mysql命令
ln -s /usr/local/mysql56/bin/mysql /usr/bin/