MySQL 错误:无法从您的 IP 地址获取主机名

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5118151/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 18:54:42  来源:igfitidea点击:

MySQL error: Can't get hostname from your ip address

mysqliphostname

提问by Jean Louis

I use my remote MySQL database during long time.

我长时间使用我的远程 MySQL 数据库。

But today I suddenly have found that I cannot connect to the database. I have got an error.

但是今天突然发现无法连接数据库。我有一个错误。

"Can't get hostname from your ip address".

“无法从您的 IP 地址获取主机名”。

I haven't changed anything in MySQL settings.

我没有更改 MySQL 设置中的任何内容。

What's the problem?

有什么问题?

回答by Ravi Parekh

Just add below in my.inior my.cnf.

只需在my.ini或下面添加my.cnf

[mysqld]

skip-name-resolve 

Linux:

Linux:

Otherwise, start MySQL server with the following flag:

否则,使用以下标志启动 MySQL 服务器:

sudo service --skip-name-resolve

For more information: http://dev.mysql.com/doc/refman/5.0/en/host-cache.html

更多信息:http: //dev.mysql.com/doc/refman/5.0/en/host-cache.html

回答by user1339124

I know this question was asked quite some time ago and most people have figured it out by now, but for those who haven't, here was my solution:

我知道这个问题很久以前就有人问过了,现在大多数人已经弄明白了,但对于那些还没有弄明白的人,这是我的解决方案:

Add the port number with the server name in you connection string

在连接字符串中添加带有服务器名称的端口号

connectionstring = "server=server;Port=3306;User Id=UserNAme;password=password;Persist Security Info=True;database=DatabaseName;convert zero datetime=true";

回答by Tianzi

I've got the same error message on windows. I found my problem is the local server host file. Check the localhost or any hostname you use in the file c:\windows\system32\drivers\etc\host

我在 Windows 上收到了相同的错误消息。我发现我的问题是本地服务器主机文件。检查本地主机或您在文件 c:\windows\system32\drivers\etc\host 中使用的任何主机名

My original host file: 127.0.0.1 localhost ::1 localhost

我的原始主机文件:127.0.0.1 localhost ::1 localhost

I just delete the second line and use the first line only: 127.0.0.1 localhost

我只是删除第二行并仅使用第一行:127.0.0.1 localhost

Then, problem solved, for my problem. Hope it helps.

然后,问题解决了,对于我的问题。希望能帮助到你。

回答by user3241933

I ran into this problem when installing MySQL 8 on a Windows 10 machine. Most of the solutions found on the internet are setting skip-name-resolvewhich never worked for me. At last I found out this one which worked for me:

我在 Windows 10 机器上安装 MySQL 8 时遇到了这个问题。在互联网上找到的大多数解决方案都是skip-name-resolve从未对我有用的设置。最后我发现了这个对我有用的:

netsh winsock reset

netsh winsock reset

Then reboot the computer. Also try set

然后重新启动计算机。也尝试设置

127.0.0.1 localhost

127.0.0.1 localhost

in %windir%\System32\drivers\etc\hostsif needed.

%windir%\System32\drivers\etc\hosts如果需要的话。

回答by VARUN GUPTA

To solve this problem, is by changing the name of the computer (B2to BBB) which changes the numeric value from the Hostname of computer.

要解决此问题,可以通过更改计算机的名称 ( B2to BBB) 来更改计算机主机名中的数值。