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

2019-01-22 16:07发布

问题:

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?

回答1:

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



回答2:

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