MySQL8.0已经发布GA版,当前最新GA版本为8.0.12。虽然相对于以前版本,MySQL8.0没有加入新元素,可是,通过代码重构,MySQL8.0的优化器更增强大,同时也有一些新特性,如支持索引隐藏等。mysql
可是,MySQL新版本中也有不少与先前版本不同的地方,好比在用户建立上就有不少变化。linux
1. 用户建立sql
建立用户的操做已经不支持grant的同时建立用户的方式,需先建立用户再进行受权bash
mysql> grant all on *.* to 'admin'@'%' identified by 'admin123'; ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'identified by 'admin123'' at line 1 mysql> create user 'admin'@'%' identified by 'admin123'; Query OK, 0 rows affected (0.06 sec) mysql> grant all on *.* to 'admin'@'%' ; Query OK, 0 rows affected (0.04 sec) mysql> flush privileges; Query OK, 0 rows affected (0.00 sec)
2. 用户登陆1微信
当用户密码含有字母或数字外的特殊符号登陆时,原先使用双引号或单引号均可以登陆,但在mysql8.0登陆时遇到问题,以下socket
[root@gjc18 lib]# /usr/local/mysql8.0/bin/mysql -uroot -p"root!@#123" --socket=/data/mysql/mysql3310/tmp/mysql3310.sock -bash: !@#123": event not found [root@gjc18 lib]# /usr/local/mysql8.0/bin/mysql -uroot -p'root!@#123' --socket=/data/mysql/mysql3310/tmp/mysql3310.sock mysql: [Warning] Using a password on the command line interface can be insecure. Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 22 Server version: 8.0.12 MySQL Community Server - GPL
3.低版本客户端登陆异常ide
错误号码 2058:Plugin caching_sha2_password could not be loaded优化
出现这个缘由是mysql8.0 以前的版本中加密规则是mysql_native_password,而在mysql8以后,加密规则是caching_sha2_password, 解决此问题方法有两种,一种是升级客户端驱动,一种是把mysql用户登陆密码加密规则还原成mysql_native_password。加密
若是修改用户密码加密规则可以使用以下方式:spa
1). 修改加密方式:
-- 修改密码为用不过时 mysql> ALTER USER 'root'@'%' IDENTIFIED BY 'password' PASSWORD EXPIRE NEVER; Query OK, 0 rows affected (0.02 sec) -- 修改密码并指定加密规则为mysql_native_password mysql> ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '123456'; Query OK, 0 rows affected (0.01 sec) -- 刷新权限 mysql> flush privileges; Query OK, 0 rows affected (0.01 sec) mysql>
修改完毕后再次登陆便可成功
2).使用高版本客户端
linux低版本客户端登陆时也会出现此状况,所以需使用高版本的客户端
[root@gjc18 lib]# mysql -uroot -p'123456' --socket=/data/mysql/mysql3310/tmp/mysql3310.sock mysql: [Warning] Using a password on the command line interface can be insecure. ERROR 2059 (HY000): Authentication plugin 'caching_sha2_password' cannot be loaded: /usr/local/mysql/lib/plugin/caching_sha2_password.so: cannot open shared object file: No such file or directory [root@gjc18 lib]# /usr/local/mysql8.0/bin/mysql -uroot -p'123456' --socket=/data/mysql/mysql3310/tmp/mysql3310.sock mysql: [Warning] Using a password on the command line interface can be insecure. Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 26 Server version: 8.0.12 MySQL Community Server - GPL Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
除了密码插件调整外,MySQL8.0其余几个主要的新密码策略有:
耿小厨已开通我的微信公众号,想进一步沟通或想了解其余文章的同窗能够关注我