MySQL error: cannot get hostname from your IP address

I have been using my remote MySQL database for a long time.

But today, I unexpectedly discovered that I could not connect to the database. I have a mistake.

"Unable to get hostname from your IP address."

I have not changed anything in the MySQL settings.

What is the problem?

+7
source share
4 answers

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

 [mysqld] skip-name-resolve 

Linux:

Otherwise, start the 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

+32
source

I have the same error message on Windows. I found that my problem is the local server host file. Check localhost or any hostname you use in 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 only the first line: 127.0.0.1 localhost

Then the problem is solved for my problem. Hope it helps.

0
source

I encountered this problem when installing MySQL 8 on a Windows 10 computer. Most of the solutions found on the Internet install skip-name-resolve which never worked for me. Finally, I discovered that this works for me:

netsh winsock reset

Then restart your computer. Also try installing

127.0.0.1 localhost

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

0
source

I know that this question was asked a long time ago, and most people guessed it, but for those who did not, here is my solution:

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

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

All Articles