Centos7.4 RPM 安装 MySQL8.0.17

只是安装用于测试,没有进行MySQL相关配置。

 

1. 卸载原装SQL

rpm -qa | grep mariadb 
# mariadb-libs-5.5.52-1.el7.x86_64 

rpm -e --nodeps mariadb-libs-5.5.52-1.el7.x86_64 
rpm -qa | grep mysql

2. 安装

顺序 :common - libs - client - server

mysql-community-common-8.0.15-1.el7.x86_64.rpm 
mysql-community-libs-8.0.15-1.el7.x86_64.rpm 
mysql-community-client-8.0.15-1.el7.x86_64.rpm 
mysql-community-server-8.0.15-1.el7.x86_64.rpm

3. 启动

systemctl start mysqld 

# 开机启动
systemctl enable mysqld

4. 查看临时密码

如果之前已经启动过,但是没有密码,那么先停止mysqld服务,删除日志文件再启动。

systemctl stop mysqld 

# 查找文件 
find / -name mysql -print 

# 删除文件 
rm -rf /var/log/mysqld.log 
rm -rf /var/lib/mysql 
rm -rf /usr/lib64/mysql 

# 重启 
systemctl start mysqld 

# 查看密码 
grep 'temporary password' /var/log/mysqld.log 

# 2020-07-08T19:04:43.896899Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: ?#FYjMp;X3F/

5. 登录

mysql -uroot -p
#Enter password: 

6. 修改密码

alter user 'root'@'localhost' identified by '123456';

 提示密码过于简单

ERROR 1819 (HY000): Your password does not satisfy the current policy requirements

调整密码强度后再设置 

# 设置密码强度低
set global validate_password_policy=0;
 
# 设置密码长度,最少4位
set global validate_password_length=4;

 

7.  修改权限

use mysql; 
update user set host = "%" where user='root'; 
flush privileges;
quit;

 

 

你可能感兴趣的:(MySQL)