11

I use my remote MySQL database during long time.

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".

I haven't changed anything in MySQL settings.

What's the problem?

4
  • tried ping yourMySQLHostIP ?
    – Nishant
    Feb 25, 2011 at 14:07
  • I have restarted the MySQL service on the remote server but it did not help.
    – Jean Louis
    Feb 25, 2011 at 14:07
  • I have a site on the same server. It works fine if I type the IP of the server into the browser address bar.
    – Jean Louis
    Feb 25, 2011 at 14:12
  • 2
    As the error states : MySQL is unable to resolve your current IP to a hostname (ie. it cannot perform a reverse lookup on your current IP). Check this bug report and also how MySQL uses DNS for some background info.
    – wimvds
    Feb 25, 2011 at 15:06

5 Answers 5

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

1
  • 2
    i am having same problem. Can anyone explain how to resolve it. This answer is not clear to me.
    – Sajal
    Nov 25, 2013 at 6:59
0

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";
0

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.

0

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.

0

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.