一、下载
https://downloads.mysql.com/archives/community/
mysql-5.7.19-linux-glibc2.12-x86_64.tar.gz
二、安装
# 删除旧环境 rpm -qa | grep mysql rpm -qa | grep mariadb rpm -e --nodeps <包名> # 强制删除包 rm -rf /etc/my.cnf rm -rf /etc/mysql # 安装依赖包 yum install libaio yum install libtinfo.so.5 # 上传包到opt目录,解压 cd /opt tar zxvf mysql-5.7.19-linux-glibc2.12-x86_64.tar.gz mv mysql-5.7.19-linux-glibc2.12-x86_64 mysql # 创建用户和目录 groupadd mysql useradd -r -g mysql -s /bin/false mysql mkdir -p /opt/mysql/data mkdir -p /opt/mysql/logs chown -R mysql:mysql /opt/mysql # 修改配置文件 vi /etc/my.cnf ------------------------------------------ [mysqld] port=3306 basedir=/opt/mysql datadir=/opt/mysql/data socket=/opt/mysql/data/mysql.sock pid-file = /opt/mysql/data/mysql.pid log-error = /opt/mysql/logs/error.log character-set-server=utf8mb4 [mysql] default-character-set=utf8mb4 [client] socket=/opt/mysql/data/mysql.sock ------------------------------------------ # 初始化数据库 bin/mysqld --initialize --user=mysql --basedir=/opt/mysql --datadir=/opt/mysql/data # 修改启动脚本 vi support-files/mysql.server ------------------------------------------ basedir=/opt/mysql datadir=/opt/mysql/data ------------------------------------------