1、下载命令:
wget https://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm
2、然后进行repo的安装:
rpm -ivh mysql57-community-release-el7-9.noarch.rpm
3、进入 /etc/yum.repos.d/目录下
cd /etc/yum.repos.d/
4、进行安装
yum install mysql-server
5、启动mysql
systemctl start mysqld #启动MySQL
systemctl stop mysqld #关闭MySQL
systemctl restart mysqld #重启MySQL
systemctl status mysqld #查看MySQL的运行状态
systemctl enable mysqld #开机自启
systemctl disable mysqld #取消开机自启
6、获取临时密码
grep 'temporary password' /var/log/mysqld.log
7、使用获取的临时密码登录mysql
mysql -u root -p
8、修改密码
ALTER USER 'root'@'localhost' IDENTIFIED BY '@abcd123456';
9、开启远程访问
mysql -u root -p #登录mysql
use mysql; #使用mysql数据库
update user set Host='%' where User='root';#% 代表任意的客户端,可替换成具体IP地址。
flush privileges; #刷新