下载mysql源安装包
wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm
安装mysql源
yum localinstall mysql57-community-release-el7-8.noarch.rpm
检查mysql源是否安装成功
yum repolist enabled | grep "mysql.*-community.*"
安装
yum install mysql-community-server
如果出现
No match for argument: mysql-community-server Error: Unable to find a match: mysql-community-server
则运行
yum module disable mysql yum -y install mysql-community-server
启动mysql
systemctl start mysqld
设置开机自启
systemctl enable mysqld
修改root本地登录密码
# 查看初始密码
grep 'temporary password' /var/log/mysqld.log
# 登陆并输入初始密码
mysql -uroot -p
#修改密码
ALTER USER 'root'@'localhost' IDENTIFIED BY 'YourPassWd!!';
# 或者
set password for 'root'@'localhost'=password('YourPassWd!!');
设置远程登陆用户
GRANT ALL PRIVILEGES ON *.* TO 'username'@'%' IDENTIFIED BY 'YourPassWd!!' WITH GRANT OPTION;
#刷新权限
flush privileges;
评论区