跳到主要内容

连接到远程的 MySQL

一、通过 dtatagrip 远程登录 mysql

二、连接到远程 MySQL 失败

1、排除网络问题

  1. ping ip ping 命令不一定能够是通的,因为有点服务器会禁用 ping 命令。
  2. telnet ip port 检查端口是否开放。

一般需要关闭防火墙或者开放出数据库的端口(3306,可以通过修改 /etc/my.cnf 中的 port 来指定 mysql 占用的端口)。

2、通过 Datagrip 远程登录 MySQL 失败。

mysql 默认不允许用户远程登录。可以通过 select * from mysql.user 查看。

允许任意 HOST 远程登录到 MySQL 中。

update user set host = '%' where user = 'root';
-- 必须执行 flush privileges;
flush privileges;

此时,就可以远程登录到 MySQL 系统了。

3、Plugin caching_sha2_password could not be loaded

解决方案:

alter user 'root'@'%' identified with mysql_native_password by 'newpassword';