1.安装依赖
https://dev.mysql.com/doc/refman/5.7/en/source-installation.html
sudo apt install make cmake gcc g++ perl bison libaio-dev libncurses5 libncurses5-dev libnuma-dev
2.mysql源码获取
版本:5.7.17
地址:https://dev.mysql.com/downloads/mysql/
选项:Source Code --> Generic Linux (Architecture Independent) -->mysql-5.7.17.tar.gz
3.解压获取源代码
tar xzvf mysql-5.7.17.tar.gz
cd mysql-5.7.17
4.手动安装boost_1_59
下载boost_1_59_0
源代码地址:·https://sourceforge.net/projects/boost/files/boost/1.59.0/boost_1_59_0.tar.gz]
tar xzvf boost_1_59_0.tar.gz
cd boost_1_59_0
sudo ./bootstrap.sh
sudo ./b2 install
5.编译安装mysql
cd mysql-5.7.17
cmake . -DBUILD_CONFIG=mysql_release -DCPACK_MONOLITHIC_INSTALL=ON -DCMAKE_INSTALL_PREFIX=/usr/opt/mysql -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DMYSQLX_TCP_PORT=33060 -DMYSQL_UNIX_ADDR=/usr/opt/mysql/mysql.sock -DMYSQL_TCP_PORT=3306 -DMYSQLX_UNIX_ADDR=/usr/opt/mysql/mysqlx.sock -DMYSQL_DATADIR=/usr/opt/mysql/data -DSYSCONFDIR=/usr/opt/mysql/etc -DENABLE_DOWNLOADS=ON -DWITH_BOOST=system
sudo make
sudo make install
6.初始化设置mysql
sudo groupadd mysql
sudo useradd -r -g mysql -s /bin/false mysql
#更改mysql目录权限
cd /usr/local/mysql
sudo chown -R mysql .
sudo chgrp -R mysql .
#初始化mysql,生成root用户的临时密码,如root@localhost: sL3>%PEjt-ir
sudo bin/mysqld --initialize --user=mysql
#开启SSL功能
sudo bin/mysql_ssl_rsa_setup
#更改mysql目录权限
sudo chown -R mysql .
sudo chgrp -R mysql .
7.测试启动mysql
sudo bin/mysqld_safe --user=mysql
8.启动mysql,输入临时密码后更改密码,停止mysql
sudo support-files/mysql.server start
sudo bin/mysql -u root -p
alter user 'root'@'localhost' identified by 'root';
sudo support-files/mysql.server stop
9.将mysql服务放置init.d目录下
sudo cp support-files/mysql.server /etc/init.d/mysql.server
service控制mysql服务
service mysql.server start|stop|restart|reload|force-reload|status