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

前端 未结 5 711
深忆病人
深忆病人 2020-12-14 04:39

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.

相关标签:
5条回答
  • 2020-12-14 05:14

    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

    0 讨论(0)
  • 2020-12-14 05:21

    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 讨论(0)
  • 2020-12-14 05:25

    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 讨论(0)
  • 2020-12-14 05:25

    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 讨论(0)
  • 2020-12-14 05:30

    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.

    0 讨论(0)
提交回复
热议问题