1.下载官方源码
2.编译安装MysqL前的准备工作
sudo yum install gcc gcc-c++ ncurses-devel perl -y
3.编译安装cmake
tar xzvf cmake-3.0.2.tar.gz
cd cmake-3.0.2
./bootstrap
make
make install
4.添加MysqL用户和组
sudo useradd myslq
5.建立MysqL需要的目录
mkdir -p /usr/local/MysqL
mkdir -p /data/MysqLdb
chmod -R MysqL:MysqL /usr/local/MysqL
chmod -R MysqL:MysqL /data/MysqLdb
6.编译安装MysqL
编译选项 | 选项说明 |
---|---|
-DCMAKE_INSTALL_PREFIX=dir_name | @H_403_60@设置MysqL安装目录|
-DMysqL_UNIX_ADDR=file_name | @H_403_60@设置监听套接字路径|
-DDEFAULT_CHARSET=charset_name | @H_403_60@设置服务器的字符集|
-DDEFAULT_COLLATION=collation_name | @H_403_60@设置服务器的排序规则|
-DMysqL_DATADIR=dir_name | @H_403_60@设置MysqL数据库文件目录|
-DMysqL_TCP_PORT=port_num | @H_403_60@设置监听套接字的端口
tar -zxv -f MysqL-5.6.22.tar.gz
cd MysqL-5.6.22
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/MysqL -DMysqL_UNIX_ADDR=MysqL.MysqL -DDEFAULT_CHARSET=gbk -DDEFAULT_COLLATION=gbk_chinese_ci -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DMysqL_DATADIR=/data/MysqLdb -DMysqL_TCP_PORT=3306 -DENABLE_DOWNLOADS=1
make && make install
cd /usr/local/MysqL
7.复制MysqL服务的配置文件和启动脚本
原文链接:https://www.f2er.com/centos/379799.htmlscripts/MysqL_install_db --user=MysqL --datadir=/data/MysqLdb cp support-files/MysqL.server /etc/init.d/MysqLdcp /usr/local/MysqL/support-files/my-default.cnf /etc/my.cnf cp support-files/MysqL.server /etc/init.d/MysqLdvim /etc/profilePATH=/usr/local/MysqL/bin:/usr/local/MysqL/lib:/$PATHexport PATHsource /etc/profile启动MysqL:service MysqLd start加入开机启动:chkconfig --level 35 MysqLd on