获取源下载地址
右键复制到下载地址:https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm
安装
wget https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm
yum -y localinstall mysql80-community-release-el7-3.noarch.rpm
# 安装mysql下载东西较多,网速慢可能要较长时间
yum -y install mysql-community-server
启动
systemctl start mysqld
# 设置开机启动
systemctl enable mysqld
systemctl daemon-reload
# 重启命令
systemctl restart mysqld
用户设置
# mysql初次启动会生成默认密码,需要到日志文件搜索
grep "A temporary password is generated for root@localhost" /var/log/mysqld.log
# 登录mysql
mysql -uroot -p
# 修改root密码
ALTER USER 'root'@'localhost' IDENTIFIED BY 'Root233!@#';
# 创建可远程登录用户
CREATE USER 'mysql'@'%' IDENTIFIED BY 'Mysql233!@#';
# 用户授权
GRANT ALL ON *.* TO 'mysql'@'%';
# 下面修改密码策略,否则会登录失败
use mysql;
ALTER USER 'mysql'@'%' IDENTIFIED BY 'Mysql233!@#' PASSWORD EXPIRE NEVER;
ALTER USER 'mysql'@'%' IDENTIFIED WITH mysql_native_password BY 'Mysql233!@#';
FLUSH PRIVILEGES;
配置文件地址:/etc/my.cnf