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?

Rubens Mariuzzo
  • 28,358
  • 27
  • 121
  • 148
Jean Louis
  • 1,485
  • 8
  • 18
  • 33
  • tried `ping yourMySQLHostIP` ? – Nishant Feb 25 '11 at 14:07
  • I have restarted the MySQL service on the remote server but it did not help. – Jean Louis Feb 25 '11 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 '11 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](http://bugs.mysql.com/bug.php?id=52923) and also [how MySQL uses DNS](http://dev.mysql.com/doc/refman/5.0/en/dns.html) for some background info. – wimvds Feb 25 '11 at 15:06

5 Answers5

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

Ravi Parekh
  • 5,253
  • 9
  • 46
  • 58
  • 2
    i am having same problem. Can anyone explain how to resolve it. This answer is not clear to me. – Sajal Nov 25 '13 at 06: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";
user1339124
  • 33
  • 1
  • 4
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.

Tianzi
  • 1
  • 1
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.

nokogiri
  • 35
  • 5
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.

ΩmegaMan
  • 29,542
  • 12
  • 100
  • 122