MySQL无法连接到远程服务器 [英] MySQL unable to connect with remote server

查看:551
本文介绍了MySQL无法连接到远程服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们在一个远程虚拟机(Windows Server 2008)中有一台MySQL服务器.到昨天为止,借助本地计算机上安装的工作台,我们能够连接到MySQL服务器.

We have a MySQL server in one of the remote Virtual Machine (Windows Server 2008). Till yesterday we were able to connect to the MySQL server, with the help of workbench installed in our local machine.

昨天,重新启动了安装了虚拟机的计算机.之后,我们将无法连接到MYSQL.虽然我可以ping和远程连接此特定的VM.我什至可以在VM中安装的工作台中执行查询.

Yesterday there was a restart to the machine which has the Virtual Machine installed. After that we are unable to connect to MYSQL. Though I can ping and remote connect this particular VM. I can even execute the queries inside the workbench installed in the VM.

我不太擅长网络或与安全相关的工作.请帮我解决这个问题.

I am not too good at networking or security related stuffs. Please help me to solve this issue.

错误:

用户"root"从主机到服务器在ABC上的连接尝试失败:3306:无法连接到"ABC"上的MySQL服务器(10060)

Your connection attempt failed for user 'root' from your host to server at ABC:3306: Can't connect to MySQL server on 'ABC' (10060)

推荐答案

确实这可能是一个很大的可能原因,希望这是一个开始:

Really this could be a magnitude of possible reasons, hopefully this is a start:

检查基本网络

从MySQL虚拟机打开命令提示符,然后键入IPCONFIG /ALL.这将显示绑定到不同网络适配器的所有IP地址.

From the MySQL virtual machine open up a command prompt and type IPCONFIG /ALL. This will show you all the IP addresses bound to different network adapters.

检查您所连接的IP地址是否在此处列出,虚拟机重启后可能已从DHCP获得了新IP,而不是具有静态IP.

Check that the IP address you're connected to is listed there, the virtual machine might have got a new IP from DHCP rather than having a static IP after its restart.

主机名与IP

您应该检查主机名解析,从引述的错误中可以看出您正在连接的是主机名而不是服务器IP.检查您的计算机可以使用正确的IP地址解析为主机名-在连接字符串中更改服务器实际IP的主机名也很值得.

You should check the hostname resolution, from your quoted error it would suggest you are you are connecting to a hostname rather than a server IP. Check your machine can resolve to the hostname using the correct IP address - it could also be worth changing the hostname for the actual IP of the server in the connection string.

MySQL配置文件

您已经说过您正在Windows上运行MySQL,习惯上是将my.cnf重命名为my.ini. 4.1.5之前版本的MySQL较早版本的配置文件通常存储在c:\my.inic:\windows\my.ini中.对于此后的版本,默认位置通常是安装目录%PROGRAMDATA%\MySQL\MySQL Server xxx.

You've said you're running MySQL on Windows, it was customary to rename the my.cnf to my.ini. The configuration file for older versions of MySQL previous to 4.1.5 was usually stored in either c:\my.ini or c:\windows\my.ini. For versions after this the default location is the installation directory usually %PROGRAMDATA%\MySQL\MySQL Server xxx.

找到配置文件后,请在记事本(或类似的文本编辑器)上将其打开,找到[mysqld]部分,并确保port=您要连接的端口和bind-address= IP您尝试连接的地址.

When you have located the configuration file please open it on Notepad (or similar text editor), locate the [mysqld] section and make sure that port= the port you're trying to connect to and bind-address= the IP address you're trying to connect to.

服务器端口

在MySQL虚拟服务器上,打开命令提示符并键入netstat –ano,这将向您显示进程列表以及它们正在侦听的IP/端口. MySQL服务器应在此处列出,并且应在配置文件所定义的端口和IP上进行监听.

From the MySQL virtual server open a command prompt and type netstat –ano, this will show you a list of processes and what IP's / ports they are listening on. The MySQL server should be listed here and should be listening on the same port and IP as the config file defines.

Windows防火墙

您应该具有允许MySQL的防火墙规则,以下内容将在默认端口3306上添加一个

You should have a firewall rule to allow MySQL, the following will add one on the default port of 3306

netsh advfirewall firewall add rule name="MySQL Server" action=allow protocol=TCP dir=in localport=3306

确定这是否是特定于机器的

您可以在另一个工作站上安装MySQL Workbench应用程序,然后尝试连接以识别这是全局问题还是仅仅是与您的特定工作站相关的一个问题.

You could setup the MySQL Workbench application on another workstation and try to connect to identify if this is a global problem or just one related to your specific workstation.

这篇关于MySQL无法连接到远程服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆