步骤如下:
1. 安装所需的依赖
yum -y install wget gcc gcc-c++ make cmake bison-devel ncurses-devel perl perl-devel perl-Data-Dumper
2. 下载MySQL 5.7源码
cd /usr/local/src wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.35.tar.gz tar -zxvf mysql-5.7.35.tar.gz
3. 编译MySQL 5.7
mkdir /usr/local/mysql cd mysql-5.7.35/ cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/usr/local/mysql/data -DWITH_BOOST=boost/boost_1_59_0/ make make install
4. 创建MySQL用户和组
useradd mysql groupadd mysql chown -R mysql:mysql /usr/local/mysql/ cd /usr/local/mysql/ ./mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
5. 启动MySQL服务
cp support-files/mysql.server /etc/init.d/mysqld chmod 755 /etc/init.d/mysqld service mysqld start
6. 设置MySQL的root密码
mysql_secure_installation
以上就是在CentOS 7中编译安装MySQL 5.7的步骤。常常情况下,MySQL的二进制包已发布到各大发行版仓库中,大家也可以直接从仓库中安装,不过这里就不在赘述了。