转载注明出处:https://blog.csdn.net/zouguo1211/article/details/83867896
前言
系统信息:CentOS Linux release 7.5.1804 (Core)
MySQL版本:mysql-5.7
接下来的操作均是在root权限下安装配置,如果使用非root账户,涉及权限要求,请使用sudo命令
由于在CentOS下装MySQL5.7踩了不少坑,打算重新走一遍,记录下来成功流程;
离线方式(解决在线下载速度过慢)请看文章末尾2019/7/19的更新;
卸载自带的Mariadb
三条命令即可
rpm -qa|grep maria*
yum -y remove maria*
rm -rf /var/lib/mysql/*
如果之前下载安装过mysql,请也先卸载干净
下载安装yum源
选择适合自己系统的版本
点击Download
复制链接地址,wget命令下载yum源
wget https://dev.mysql.com/get/mysql80-community-release-el7-1.noarch.rpm
输入命令安装源:
yum -y install mysql80-community-release-el7-1.noarch.rpm
安装Mysql服务器
上述安装的源,默认安装Mysql8.0,我们需要修改下配置,来指定安装5.7版本:
命令行输入:
vim /etc/yum.repos.d/mysql-community.repo
保存写入;
然后输入命令安装服务器==(此过程需要联网)==:
yum -y install mysql-community-server
启动Mysql服务
修改data文件目录
vim编辑/etc/my.cnf文件
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html
[mysqld]
#
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
#
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
#
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find