Navicat Premium工具无法连接mysql数据库
作者:
来源:本站原创
点击数: 次
发布时间:2023年03月05日
QQ图片20230305195546
1.在数据库服务器端登录mysql -u root -p
2.查询数据库加密方式为caching_sha2_password
mysql> use mysql; select user,plugin from user where user='root';
QQ图片20230305195723
3.查看root的host是'%'
mysql> select user,host from user; +------------------+-----------+ | user | host | +------------------+-----------+ | root | % | | admin | localhost | | mysql.infoschema | localhost | | mysql.session | localhost | | mysql.sys | localhost | | zhangj | localhost | +------------------+-----------+
4.alter user 'root'@'%' identified with mysql_native_password by '密码';
5.再次查看加密方式已经变为mysql_native_password
select user,plugin from user where user='root';
QQ图片20230305195750
6.找到/etc/my.cnf文件
在[mysqld]节点下添加default_authentication_plugin=mysql_native_password
QQ图片20230305195823
7.保存后,重启mysql服务命令:mysql.server restart