mysql_8 yum安装教程

安装MySQL8.0资源库

yum localinstall https://repo.mysql.com//mysql80-community-release-el7-1.noarch.rpm

安装MySQL8.0

yum install mysql-community-server

启动MySQL并配置开机自启

systemctl start mysqld
systemctl enable mysqld

查看默认密码并重置

查看密码

grep 'temporary password' /var/log/mysqld.log

mysql_8 yum安装教程

登录并重置密码

mysql -pt&ki3u&+ib7X
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements

这个与validate_password_policy的值有关, mysql8.0更改了validate_password_policy相关的配置, 这跟Mysql5.7有点不一样

修改密码校验规则与密码长度

mysql> set global validate_password.policy=0;
Query OK, 0 rows affected (0.00 sec)
 
mysql> set global validate_password.length=1;
Query OK, 0 rows affected (0.00 sec)

继续修改密码

mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';
Query OK, 0 rows affected (0.03 sec)

退出后重新登录

使用MySQL8.0踩的坑

授权方式改变
mysql5.7

mysql> grant all privileges on *.* to 'kevin'@'%' ;

mysql8.0

mysql> grant all privileges on *.* to 'kevin'@'%' with grant option;

无法远程连接

MySQL8.0默认是不能使用root账户远程登录的

修改为可以远程登录

mysql> update mysql.user set host='%' where user="root";
mysql> flush privileges;

加密规则的改变
mysql8 之前的版本中加密规则是mysql_native_password, 而在mysql8之后,加密规则是caching_sha2_password

使用navicat进行mysql登录时出现弹窗报错
mysql_8 yum安装教程
修改方式一是:升级navicat驱动,二是:把MySQL用户登录密码加密规则还原成mysql_native_password

#修改加密规则
mysql> ALTER USER 'root'@'%' IDENTIFIED BY '123456' PASSWORD EXPIRE NEVER;       
Query OK, 0 rows affected (0.16 sec)
 
#更新一下用户的密码
mysql> ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '123456';
Query OK, 0 rows affected (0.08 sec)
 
#刷新权限
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.03 sec)

update修改密码,密码字段名称更改

mysql>update user set authentication_string=password("root") where user='root' and host='localhost';

上一篇:Swift相册照片选择-支持单选或多选


下一篇:MySQL学习总结之路(第三章:数据类型)