1. 安装Centos 7,以保证其依赖库版本号为较新的。
2.安装cmake3.11.0,版本要求2.9以上,官网可以下载源码。
2.1 解压 tar -zxf cmake-3.11.0-rc2.tar.gz
2.2 ./bootstrap
2.3 gmake && gmake install
3. 安装依赖库和程序
3.1 gcc,g++采用4.8版本
3.2 bison
3.3.zlib, zlib-devel
3.4 libxml
3.5 openssl
3.6 ncurses-devel
yum -y install gcc,g++,bison, zlib, zlib-devel, libxml, openssl, ncurses-devel
4. boost安装
4.1 ./bootstrap
4.2 ./b2 install
5. 创建mysql用户,组
groupadd mysql
useradd -s /sbin/nologin -M -g mysql
6. 解压源码包后,cmake mysql,不带my.cnf也能安装示例如下:
cmake . -DCMAKE_INSTALL_PREFIX=/application/mysql-5.7.32 \
-DMYSQL_DATADIR=/application/mysql-5.7.32/data \
-DEXTRA_CHARSETS=gbk,gb2312,utf8,ascii \
-DENABLED_LOCAL_INFILE=ON \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_FEDERATED_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITHOUT_EXAMPLE_STORAGE_ENGINE=1 \
-DWITHOUT_PARTITION_STORAGE_ENGINE=1 \
-DWITH_FAST_MUTEXES=1 \
-DWITH_ZLIB=bundled \
-DENABLED_LOCAL_INFILE=1 \
-DWITH_READLINE=1 \
-DWITH_EMBEDDED_SERVER=1 \
-DWITH_DEBUG=0\
-DDOWNLOAD_BOOST=1 \
-DWITH_BOOST=/usr/src/boost_1_59_0
7. make && make install
8. 修改PATH系统变量
echo "export PATH=/application/mysql-5.7.32/bin:$PATH" >> /etc/profile
source /etc/profile
9. cp /application/mysql-5.7.32/support-files/mysql.server /etc/init.d/mysql 注意必须有x权限
chkconfig --add mysql
chkconfig --level 2345 mysql on
10. chown -R mysql. mysql /application/mysql-5.7.32
mkdir -p /application/mysql-5.7.32/data
chown -R mysql.mysql /application/mysql-5.7.32/data
11. mysql_install_db --basedir=/application/mysql-5.7.32/ --datadir=/application/mysql-5.7.32/data/ --user=mysql
12. service mysql start
13.cat /root/.mysql_secret获取root账户密码
14.mysql -u root -p 使用获取到的密码登录
15.修改root账户密码
ALTER USER "root" IDENTIFIED BY "root";
UPDATE mysql.user SET PASSWORD=PASSWORD("root") WHERE user='root' and host="localhost";
flush privileges;