CentOS7-yum安装MySQL5.7

时间:2022-06-04 21:05:41

1. 下载并安装MySQL官方repository

wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm

然后安装

yum -y install mysql57-community-release-el7-10.noarch.rpm

然后安装mysql服务器

yum -y install mysql-community-server

 

2.配置mysql数据库

首先启动数据库

systemctl start mysqld.service  --启动 systemctl stauts mysqld.service --查看状态 grep "password" /var/log/mysqld.log --查看root默认密码

登陆数据库

mysql -u root -p 默认密码 ALTER USER 'root'@'localhost' IDENTIFIED BY 'new password'; 或 set password for 'root'@'localhost'=password('MyNewPass4!'); 或 update mysql.user set authentication_string=password('123456') where user='root' ;

配置mysql可以设置简单密码

set global validate_password_policy=0; set global validate_password_length=1; 或 在 vim /etc/my.cnf配置文件中增加: validate_password=off default_password_lifetime=0

查看密码规则

show variables like '%password%';

卸载mysql Repository,不然每次yum会自动更新

yum -y remove mysql57-community-release-el7-10.noarch