centos 7.4
mysql-8.0.17
1, 下载mysql源码包
https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-boost-8.0.17.tar.gz
2, 创建mysql用户
useradd -s /bin/false mysql
3, 安装依赖
yum -y install gcc gcc-c++ ncurses ncurses-devel libaio-devel openssl openssl-devel
源码安装cmake3(本机yum源没有3版本)
./bootstrap --prefix=/usr/local/cmake
gmake
gmake install
ln -s /usr/local/cmake/bin/cmake /usr/bin/cmake
4, 解压mysql并进入执行,首次尝试安装
cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/data/mysql -DSYSCONFDIR=/etc -DWITH_BOOST=boost -DFORCE_INSOURCE_BUILD=1
这里的数据目录 /data/mysql 需要填你自己的目录
下载gcc源码包
http://ftp.gnu.org/gnu/gcc/gcc-9.2.0/gcc-9.2.0.tar.gz
./configure
下载 gmp、mpfr、mpc源码包
ftp://ftp.gnu.org/gnu/mpc/mpc-1.0.2.tar.gz
ftp://ftp.gnu.org/gnu/gmp/gmp-5.0.1.tar.bz2
http://ftp.gnu.org/gnu/mpfr/mpfr-3.1.2.tar.gz
tar -jxvf gmp-5.0.1.tar.bz2
cd gmp-5.0.1
./configure --prefix=/usr/local/gmp-5.0.1
make
make install
tar -zxvf mpfr-3.1.2.tar.gz
cd mpfr-3.1.2
./configure --prefix=/usr/local/mpfr-3.1.2 --with-gmp=/usr/local/gmp-5.0.1
make
make install
tar -zxvf mpc-1.0.2.tar.gz
cd mpc-1.0.2
./configure --prefix=/usr/local/mpc-1.0.2 --with-gmp=/usr/local/gmp-5.0.1 --with-mpfr=/usr/local/mpfr-3.1.2
make
make install
安装三个依赖库完毕之后记住一定要把库路径添加到 /etc/ld.so.conf文件中
vim /etc/ld.so.conf
/usr/local/gmp-5.0.1/lib
/usr/local/mpfr-3.1.2/lib
/usr/local/mpc-1.0.2/lib
添加路径完之后一定要执行
ldconfig
rm -f CMakeCache.txt
./configure --prefix=/usr/local/gcc-9.2.0 --enable-threads=posix --disable-checking --enable--long-long --with-gmp=/usr/local/gmp-5.0.1 --with-mpfr=/usr/local/mpfr-3.1.2 --with-mpc=/usr/local/mpc-1.0.2 --disable-multilib
make
make install
mv /usr/bin/gcc /usr/bin/gcc4.8.5
mv /usr/bin/g++ /usr/bin/g++4.8.5
设置新版本gcc
ln -s /usr/local/gcc-9.2.0/bin/gcc /usr/bin/gcc
ln -s /usr/local/gcc-9.2.0/bin/g++ /usr/bin/g++
5, 第二次尝试安装mysql
cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/data/mysql -DSYSCONFDIR=/etc -DWITH_BOOST=boost -DFORCE_INSOURCE_BUILD=1 -DCMAKE_CXX_COMPILER=/usr/bin/g++
make
此处参考链接:https://blog.csdn.net/ZX714311728/article/details/69628836
6, 解决上面问题,再次执行make(第三次尝试安装mysql)
make -j 10
解决办法:在文件buf0buf.cc的开头添加: #include “sys/syscall.h”
7,第四次尝试安装mysql
解决办法:将lock0lock.cc.o 中 “os_compare_and_swap_thread_id” 修改为 os_compare_and_swap_lint
8, 第五次尝试安装mysql
解决办法: 将trx0trx.cc 中 “os_compare_and_swap_thread_id” 修改为 os_compare_and_swap_lint
注意: 这里有两处需要替换
9, 第六次尝试安装mysql
make
make install
通过了!!!
10 ,下面做些常规配置
配置 mysql
vim /etc/my.conf
[mysqld]
basedir=/usr/local/mysql
datadir=/data/mysql
[client]
socket=/var/lib/mysql/mysql.sock
保存退出
chown -R mysql:mysql /usr/local/mysql
chown -R mysql:mysql /data/mysql
chmod -R 755 /usr/local/mysql
chmod -R 755 /data/mysql
配置启动脚本
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
chkconfig --add mysqld
chkconfig mysqld on
11, 启动mysql
service mysqld start
mkdir /var/log/mariadb
touch mariadb.log
chown mysql:mysql /var/log/mariadb/ -R
chmod 755 /var/log/mariadb/ -R
service mysqld start # success!!!
12, 登录mysql
设置mysql 快捷方式
ln -s /usr/local/mysql/bin/mysql /usr/bin/mysql
开始登录
mysql -uroot -p
这里很懵逼,因为安装过程中没有要求我输入密码的地方,这里却让我输入密码。。。
此处解决办法:https://blog.csdn.net/rdisme/article/details/54599569
https://blog.csdn.net/lwbeyond/article/details/77718040
https://blog.csdn.net/ZX714311728/article/details/69628836
https://www.nmirage.com/database/492.html
https://www.cnblogs.com/jjg0519/p/9034713.html
https://www.cnblogs.com/NanZhiHan/p/11017158.html