MySQL通过SSH隧道远程访问错误

时间:2022-06-05 02:48:26

I've created an SSH tunnel on my local machine to reach an access to the mysql server on my remote machine. Everything is fine, tunnel is working if I get this error, but why this error occurs?

我在本地计算机上创建了一个SSH隧道,以访问远程计算机上的mysql服务器。一切都很好,如果我收到此错误隧道正在工作,但为什么会出现此错误?

Here is the error message:

这是错误消息:

2013 - Lost connection to MySQL server at 'reading initial communication packet', system error: 0

2013 - 在“读取初始通信数据包”时丢失与MySQL服务器的连接,系统错误:0

It happends only, when I want to connect via Navicat (SSH Tunnel) from my local to the remote machine, on the remote machine mysql works without such errors.

它只发生,当我想通过Navicat(SSH隧道)从我的本地连接到远程机器,在远程机器上mysql工作没有这样的错误。

Have you guys any solutions for that?

你们有任何解决方案吗?

2 个解决方案

#1


2  

This error occurs when the configuration of the bind-adress option is wrong. Your MySQL server at least should listen on the localhost - 127.0.0.1

bind-adress选项的配置错误时会发生此错误。你的MySQL服务器至少应该监听localhost - 127.0.0.1

#2


1  

Login to your local Linux machine then run this command:

登录到本地Linux计算机,然后运行以下命令:

ssh -L 3307:localhost:3306 -N user@remote.server.com

Use the mysql database from remote server:

使用远程服务器的mysql数据库:

mysql -u root -p --port 3307 -h 127.0.0.1

Make sure the local mysql does not use the same port in Linux environment.

确保本地mysql在Linux环境中不使用相同的端口。

#1


2  

This error occurs when the configuration of the bind-adress option is wrong. Your MySQL server at least should listen on the localhost - 127.0.0.1

bind-adress选项的配置错误时会发生此错误。你的MySQL服务器至少应该监听localhost - 127.0.0.1

#2


1  

Login to your local Linux machine then run this command:

登录到本地Linux计算机,然后运行以下命令:

ssh -L 3307:localhost:3306 -N user@remote.server.com

Use the mysql database from remote server:

使用远程服务器的mysql数据库:

mysql -u root -p --port 3307 -h 127.0.0.1

Make sure the local mysql does not use the same port in Linux environment.

确保本地mysql在Linux环境中不使用相同的端口。