下载mysql
- 下载地址
https://dev.mysql.com/downloads/mysql/
- 上传服务器解压
tar -zxvf mysql-boost-5.7.44.tar.gz
- 安装依赖
yum install -y make gcc gcc-c++ ncurses-devel
yum install bison* -y
yum install ncurses* -y
yum -y install make gcc-c++ cmake bison-devel ncurses-devel libaio libaio-devel perl-Data-Dumper net-tools
- 编译安装
cd mysql-5.7.44
mkdir build
cd build
cmake .. -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/usr/local/mysql/data -DSYSCONFDIR=/etc -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DMYSQL_UNIX_ADDR=/var/lib/mysql/mysql.sock -DMYSQL_TCP_PORT=3306 -DENABLED_LOCAL_INFILE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DEXTRA_CHARSETS=all -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_BOOST=../boost/boost_1_59_0
make && make install
## 如果编译出错
make clean
rm -rf CMakeCache.txt
## 然后重新编译安装
- 安装完成后的配置
groupadd mysql
useradd -g mysql -s /sbin/nologin mysql
## 授权
chown -R mysql:mysql /var/lib/mysql
cd /var/lib/mysql
chown -R mysql .
chgrp -R mysql .
## 初始化数据库
/var/lib/mysql/bin/mysqld \
--initialize \
--user=mysql \
--datadir=/var/lib/mysql/data