M.N*_*M.N 3 mysql windows-xp hosts-file
我在 Windows 机器上安装了 MySQL 5.5 服务器。
我可以从在同一台机器上运行的控制台/应用程序连接到服务器,但不能从远程机器连接。使用以下命令连接时:
mysql -h xx.xx.xx.xx --port=3306 -u root -p
Run Code Online (Sandbox Code Playgroud)
I get the following error:
ERROR 1042 (HY000): Can't get hostname for your address
I have tried putting the entry of client IP in server's %windir%\system32\drivers\etc\hosts
file as:
<client-ip> <client-hostname>
Run Code Online (Sandbox Code Playgroud)
小智 5
I believe this is to do with the fact that MySQL tries to establish the DNS name associated with your IP address on connect. See here for more information at the MySQL site.
You have two options:
1) Fix the connecting machine's reverse DNS. Since you've already added the machine to the hosts file, this might be unnecessary. You should also issue a FLUSH HOSTS statement on the MySQL server. See the same link above for more information about this.
2) 使用“--skip-name-resolve”选项运行 MySQL。但是,如果您这样做,您将无法在 GRANT 语句中使用 DNS 名称。相反,您将被限制使用 IP 地址。
2.1) 或放入my.ini:
[mysqld]
skip-name-resolve
Run Code Online (Sandbox Code Playgroud)
如果可以,我会推荐(1)。
希望这可以帮助。
归档时间: |
|
查看次数: |
24182 次 |
最近记录: |