mysql8.0无法连接 错误(1130)

开始表演:

mysql> show databases; +--------------------+ | Database| +--------------------+ | information_schema | | mysql| | performance_schema | | sys| +--------------------+ 4 rows in set (0.00 sec)mysql> create database test; Query OK, 1 row affected (0.01 sec)mysql> show databases; +--------------------+ | Database| +--------------------+ | information_schema | | mysql| | performance_schema | | sys| | test| +--------------------+ 5 rows in set (0.00 sec)mysql> grant all privileges on test.* to 'root'@'%'; ERROR 1410 (42000): You are not allowed to create a user with GRANT mysql> grant all privileges on test.* to 'root'@'%' identified by '1111'; ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the rightsyntax to use near 'identified by '1111'' at line 1

----挣扎一下----
mysql> grant all privileges on test.* to 'root'@'%' identified by "1111" ; 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 "1111"' at line 1

----老思路,像5.7一样,我直接赋权创建一个新用户----
事实证明,我是徒劳的~~~
mysql> grant all privileges on test.* to 'test'@'%' identified by "1111"; ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the rightsyntax to use near 'identified by "1111"' at line 1

好吧,我还是老老实实一步一步创建吧
mysql> create user 'test'@'%' identified by '1111'; Query OK, 0 rows affected (0.02 sec) mysql> grant all privileges on test.* to 'test'@'%' with grant option; Query OK, 0 rows affected (0.01 sec)

来,试一下。
mysql8.0无法连接 错误(1130)
文章图片

mysql8.0无法连接 错误(1130)
文章图片

纳尼??不行……
提示加密方式的原因(8.0的加密方式变了),我们查一下
mysql> select host,user,plugin from user; ERROR 1046 (3D000): No database selected mysql> use mysql; Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -ADatabase changed mysql> select host,user,plugin from user; +-----------+------------------+-----------------------+ | host| user| plugin| +-----------+------------------+-----------------------+ | %| test| caching_sha2_password | | localhost | mysql.infoschema | caching_sha2_password | | localhost | mysql.session| caching_sha2_password | | localhost | mysql.sys| caching_sha2_password | | localhost | root| caching_sha2_password | +-----------+------------------+-----------------------+ 5 rows in set (0.00 sec)

果然变了。我们来改一下
mysql> alter user 'test'@'%' identified with mysql_native_password ; Query OK, 0 rows affected (0.01 sec)

mysql8.0无法连接 错误(1130)
文章图片

看起来不设定密码不行的
mysql> alter user 'test'@'%' identified with mysql_native_password by '1111'; Query OK, 0 rows affected (0.01 sec)

【mysql8.0无法连接 错误(1130)】终于好了,是不是很爽?
mysql8.0无法连接 错误(1130)
文章图片

    推荐阅读