安装好 mysql 后,一般会使用客户端连接(必须Navcat)。本文描述了怎么设置远程连接。
先看下 用户表的信息
use mysql;
select host, user from user;
image.png
注意:这里的 root 账户的 host 的值是 localhost
开始修改,执行:
mysql> use mysql;
mysql> update user set host = '%' where user = 'root';
修改后:
image.png
注意:这里的 root 账户的 host 的值变成了 % % 这个百分号表示的意思是任意机器都可以连接,也可以缓存你机器的固定ip。
systemctl stop mysqld.service
systemctl start mysqld.service
# 为防火墙添加 3306 端口
firewall-cmd --zone=public --add-port=3306/tcp --permanent
# 重启防火墙
firewall-cmd --reload
高高兴兴的打开连接,发现:does not support authentication protocol
image.png
不得已,继续开始设置
select host,user,plugin,authentication_string from mysql.user;
发生这个问题的原因是 密码的加密方式 的问题。
select host,user,plugin,authentication_string from mysql.user;
注意:下图中的 plugin = cacheing_sha2_password 方式
image.png
ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'Spri636!';
执行 select host,user,plugin,authentication_string from mysql.user;
image.png
注意:上图中的 plugin = cacheing_sha2_password 方式
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有