Navicat连接mysql8.0:提示无法加载身份验证插件“caching_sha2_password”

Navicat连接mysql时,提示:Unable to load authentication plugin 'caching_sha2_password'.

原因:mysql 8.0 默认使用 caching_sha2_password 身份验证机制。

bash 复制代码
D:\MySQL8.0\install\bin>mysql -uroot -p123456789   #登录
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.32 MySQL Community Server - GPL

Copyright (c) 2000, 2023, Oracle and/or its affiliates.

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.

mysql> use mysql
Database changed
mysql> select user,host,plugin,authentication_string from user;    #查看用户信息

修改身份验证机制

bash 复制代码
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '123456';    #修改身份验证机制

更改过程:

MySQL 复制代码
mysql> mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '123456';    #修改身份验证机制
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 'mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '4' at line 1
mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '123456';
Query OK, 0 rows affected (0.07 sec)

mysql> ALTER USER 'pokes'@'%' IDENTIFIED WITH mysql_native_password BY '123456';   #修改身份验证机制 
Query OK, 0 rows affected (0.06 sec)

mysql>

MYSQL8.0开启远程链接

bash 复制代码
mysql -uroot -p123456
grant all privileges on *.* to 'root'@'%'identified by 'youpassword' with grant option;  #开启远程访问
mysql> CREATE USER 'pokes'@'%' IDENTIFIED BY '123456';		#新建一个用户
mysql> GRANT ALL PRIVILEGES ON *.* TO 'pokes'@'%' WITH GRANT OPTION;   #授权
mysql> FLUSH PRIVILEGES;    #刷新
bash 复制代码
D:\MySQL8.0\install\bin>mysql -uroot -p123456
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 19
Server version: 8.0.32 MySQL Community Server - GPL

Copyright (c) 2000, 2023, Oracle and/or its affiliates.

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.

mysql> grant all privileges on *.* to 'root'@'%'identified by 'youpassword' with grant option;
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 'youpassword' with grant option' at line 1
mysql> CREATE USER 'pokes'@'%' IDENTIFIED BY '123456';
Query OK, 0 rows affected (0.63 sec)

mysql> GRANT ALL PRIVILEGES ON *.* TO 'pokes'@'%' WITH GRANT OPTION;
Query OK, 0 rows affected (0.06 sec)

mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.08 sec)

mysql>
复制代码
![在这里插入图片描述](https://img-blog.csdnimg.cn/afbaa2a3499f4a3e847bd434e6aa1e72.png)
相关推荐
金桔数科4 小时前
在MySQL Shell里 重启MySQL 8.4实例
mysql
她和夏天一样热5 小时前
【Java面试题04】MySQL 篇
java·mysql·adb
曹天骄5 小时前
设计并实现一个基于 Java + Spring Boot + MySQL 的通用多租户权限系统
java·spring boot·mysql
一个天蝎座 白勺 程序猿6 小时前
Python爬虫(9)Python数据存储实战:基于pymysql的MySQL数据库操作详解
数据库·python·mysql
jiaoxingk7 小时前
有关爬虫中数据库的封装——单线程爬虫
数据库·爬虫·python·mysql
Suckerbin7 小时前
第十三章-PHP MySQL扩展
mysql·安全·php
小可爱的大笨蛋9 小时前
Spring AI Alibaba - MCP连接 MySQL
人工智能·mysql·spring·mcp
柳如烟@9 小时前
Hadoop伪分布式模式搭建全攻略:从环境配置到实战测试
大数据·hadoop·分布式·mysql
小白教程11 小时前
解读和分析mysql性能数据时,如何确定性能瓶颈的具体位置?
数据库·mysql·mysql教程·mysql优化教程
LaughingZhu11 小时前
PH热榜 | 2025-04-26
前端·数据库·人工智能·mysql·开源