1、CentOS7默认安装了mariadb,先查看是否安装mariadb,如果安装先卸载mariadb
rpm -qa|grep mariadb
rpm -e mariadb-libs --nodeps
2、下载源码包
yum install -y wget
wget https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-8.0.23.tar.gz
3、安装编译必要的包
yum -y install make gcc-c++ cmake bison-devel ncurses-devel
4、创建MySQL用户和组,该用户只用作MySQL的服务,不能用于登录系统
groupadd mysql
useradd -g mysql mysql -M -s /sbin/nologin
5、检验源压缩包的完整性、并解压源码包,解压到/usr/local/mysql中
md5sum mysql-8.0.23.tar.gz
tar -zxvf mysql-8.0.23.tar.gz
mv mysql-8.0.23 /usr/local/mysql
6.安装cmake3
wget https://github.com/Kitware/CMake/releases/download/v3.20.0-rc4/cmake-3.20.0-rc4.tar.gz
tar xzvf cmake-3.20.0.tar.gz
cd cmake-3.20.0
./bootstrap
gmake
sudo gmake install
cd /usr/local/mysql/
cmake -DDOWNLOAD_BOOST=1 -DWITH_BOOST=/usr/local/boost -DWITH_DEBUG=1 -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/usr/local/mysql/data -DSYSCONFDIR=/etc -DEFAULT_CHARSET=utf8mb4 -DDEFAULT_COLLATION=utf8mb4_general_ci -DENABLED_LOCAL_INFILE=1 -DEXTRA_CHARSETS=all