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

送分小仙女□ 提交于 2019-11-28 20:55:36

Just add below in my.ini or my.cnf.

[mysqld]

skip-name-resolve 

Linux:

Otherwise, start MySQL server with the following flag:

sudo service --skip-name-resolve

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

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

My original host file: 127.0.0.1 localhost ::1 localhost

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

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

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-resolve which never worked for me. At last I found out this one which worked for me:

netsh winsock reset

Then reboot the computer. Also try set

127.0.0.1 localhost

in %windir%\System32\drivers\etc\hosts if needed.

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";
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!