Unknown mysql server host ошибка

I was using mysql 5.6.11,it usually turned down and show me this:

2005 — Unknown MySQL server host ‘localhost'(11001).

Currently my resolution is to turn off the network,than it return to normal.I had searched a lot,but no answer is revalent to it.So,does anyone knows the reason?

Shadow's user avatar

Shadow

33.4k10 gold badges50 silver badges62 bronze badges

asked May 16, 2013 at 6:24

user2388626's user avatar

9

ERROR 2005 (HY000): Unknown MySQL server host ‘localhost’ (0)

modify list of host names for your system:

C:WindowsSystem32driversetchosts

Make sure that you have the following entry:

127.0.0.1 localhost
In my case that entry was 0.0.0.0 localhost which caussed all problem

(you may need to change modify permission to modify this file)

This performs DNS resolution of host “localhost” to the IP address 127.0.0.1.

answered Jul 30, 2013 at 13:52

GaneshP's user avatar

GaneshPGaneshP

7367 silver badges25 bronze badges

3

I have passed through that error today and did everything described above but didn’t work for me. So I decided to view the core problem and logged onto the MySQL root folder in Windows 7 and did this solution:

  1. Go to folder:

    C:AppServMySQL
    
  2. Right click and Run as Administrator these files:

    mysql_servicefix.bat
    
    mysql_serviceinstall.bat
    
    mysql_servicestart.bat
    

Then close the entire explorer window and reopen it or clear cache then login to phpMyAdmin again.

Mogsdad's user avatar

Mogsdad

44.5k21 gold badges150 silver badges272 bronze badges

answered Dec 2, 2015 at 19:22

Mizo Games's user avatar

Mizo GamesMizo Games

1791 silver badge8 bronze badges

The case is like :

 mysql connects will localhost when network is not up.
 mysql cannot connect when network is up.

You can try the following steps to diagnose and resolve the issue (my guess is that some other service is blocking port on which mysql is hosted):

  1. Disconnect the network.
  2. Stop mysql service (if windows, try from services.msc window)
  3. Connect to network.
  4. Try to start the mysql and see if it starts correctly.
  5. Check for system logs anyways to be sure that there is no error in starting mysql service.
  6. If all goes well try connecting.
  7. If fails, try to do a telnet localhost 3306 and see what output it shows.
  8. Try changing the port on which mysql is hosted, default 3306, you can change to some other port which is ununsed.

This should ideally resolve the issue you are facing.

Derlin's user avatar

Derlin

9,5222 gold badges29 silver badges52 bronze badges

answered May 17, 2013 at 3:44

Himanshu Bhardwaj's user avatar

3

Follow these steps to fix this error
Use connect root@127.0.0.1 instead of connect root@localhost

if it doesn’t work then go to C:WindowsSystem32driversetchosts and check the IP address attached to host name.
use that IP, so it will be.
connect root@the_ip_address_you_found

answered Apr 29, 2021 at 11:39

sule mohammed's user avatar

AWS RDS Unknown MySQL Server Host error causing trouble? Read on to resolve this issue. 

At Bobcares, we offer solutions for every query, big and small, as a part of our AWS Support Services.

Let’s take a look at how our AWS Support Team is ready to help customers resolve Unknown MySQL Server Host error.

What is AWS RDS: “Unknown MySQL Server Host” error?

Every now and then, our customers come across the “Unknown MySQL Server Host” error in AWS RDS. According to our MySQL Server experts, this error is due to internal name servers in AWS. Rather than return an IP address, they time out or return an empty answer resulting in the error. In other words. The “Unknown MySQL Server Host” error message pops up due to hostup lookup fails.

AWS RDS: Unknown MySQL Server Host error

Fortunately, our experts have come up with a solution to resolve Unknown MySQL Server Host” error.

How to resolve Unknown MySQL Server Host error

First, use the PHP function gethostbyname() to access the IP address from the DNS name as seen here:


Alternatively, here is another solution to the Unknown MySQL Server Host error:

  1. To begin with, verify the RDS instance’s endpoint is correct. If it is incorrect, it may be due to one of the following reasons:
    • Invalid endpoint format
    • Manually releasing a public endpoint
    • Endpoint exceeds maximum length
  2. If the endpoint is correct, we have to try changing the DNS server IP addresses as seen here:
    • If we connect to the RDS instance through the classic network change the DNS server IP addresses to 10.143.22.118 and 10.143.22.116.
    • In case we connect to the RDS instance through an internal network by changing the DNS server IP addresses to 100.100.2.138 and 100.100.2.136.
    • If we connect to the RDS instance through the Internet, change the DNS server IP addresses to 223.6.6.6 and 223.5.5.5.

[Need assistance with another query? We are available 24/7.]

Conclusion

In a nutshell, our skilled AWS Support Engineers at Bobcares demonstrated how to resolve the RDS Unknown MySQL Server Host error.

PREVENT YOUR SERVER FROM CRASHING!

Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

GET STARTED

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and
privacy statement. We’ll occasionally send you account related emails.

Already on GitHub?
Sign in
to your account

Closed

pcantalupo opened this issue

Feb 28, 2020

· 9 comments

Labels

question

Usability question, not directly related to an error with the image

Comments

@pcantalupo

I’m trying to follow instructions on this page to run docker mysql

$ docker run --name some-mysql -e MYSQL_ROOT_PASSWORD=my-secret-pw -d mysql
c365f36e34cd5a580d380f09be3845e84a7a8a741b5a739062d976895d353fb6

$ docker ps | grep some-mysql
c365f36e34cd        mysql               "docker-entrypoint.s…"   27 seconds ago      Up 26 seconds       3306/tcp, 33060/tcp   some-mysql

$ docker inspect bridge | grep -B2 -A5 some-mysql
        "Containers": {
            "c365f36e34cd5a580d380f09be3845e84a7a8a741b5a739062d976895d353fb6": {
                "Name": "some-mysql",
                "EndpointID": "5edbd0af493cad5c8c69525576aab0db8472e7523668104c2b23299053ed9bd6",
                "MacAddress": "02:42:ac:11:00:03",
                "IPv4Address": "172.17.0.3/16",
                "IPv6Address": ""
            },

Then I’m trying to connect to MySQL from the MySQL command line client with your example code where I replaced some_network with bridge since that is the network some-mysql is on. However I get the following error…why?

$ docker run -it --network bridge --rm mysql mysql -hsome-mysql -u root -p
Enter password: 
ERROR 2005 (HY000): Unknown MySQL server host 'some-mysql' (0)

Thank you

@tianon

Docker’s built-in DNS doesn’t apply on the default bridge network — it has to be a custom/user-created network for Docker to provide DNS resolution of containers.

@wglambert
wglambert

added
the

question

Usability question, not directly related to an error with the image

label

Feb 28, 2020

@pcantalupo

Is it possible up update your documentation to make this clearer? Thank you

@wglambert

The default bridge network behavior isn’t directly related to the image so reproducing Docker’s documentation seems unnecessary and out of scope

https://docs.docker.com/network/bridge/#differences-between-user-defined-bridges-and-the-default-bridge

Containers on the default bridge network can only access each other by IP addresses, unless you use the —link option, which is considered legacy. On a user-defined bridge network, containers can resolve each other by name or alias.

Going to close since this is resolved

@martinp999

I agree with @pcantalupo — the documentation should say something like —

«To get up and running fast —

  • docker network create mysql-net
  • docker run —network mysql-net —name some-mysql -e MYSQL_ROOT_PASSWORD=my-secret-pw -d mysql:tag
  • docker run —network mysql-net -it —rm mysql:tag mysql -hsome-mysql -uroot -p
    «
pcantalupo, hsnusonic, ox-rock, Syodini, danodriscoll, dimsa, onetwopunch, martin0327, al3jandrocabrera, jeremyvdw, and 64 more reacted with thumbs up emoji
matthew123987, bl-ue, BenBlueAlvi, darenr, tcsmith, Yop-La, AlekseiMikhalev, delayrejerrol, and samnzay reacted with hooray emoji
arseniigorkin, vmickus-meli, Relickus, and samnzay reacted with heart emoji

@wglambert

We were using --link in the images examples but changed it from the discussion in #545

docker-library/docs#1441

Ditch a lot of «—link» examples (using «—network some-network» instead to force users to do more homework)

@maaikez

I agree with @pcantalupo — the documentation should say something like —
* docker network create mysql-net
* docker run —network mysql-net —name some-mysql -e MYSQL_ROOT_PASSWORD=my-secret-pw -d mysql:tag
* docker run —network mysql-net -it —rm mysql:tag mysql -hsome-mysql -uroot -p

Would be great if this was added to the documentation.

martinp999, melissasgarden, tcsmith, jcasstevens, khituras, sebastiancadena, datatrigger, mugiwarafx, cas—, alnavv, and 3 more reacted with thumbs up emoji

@liranye

@martinp999
using your advice I still get the following error:
ERROR 2003 (HY000): Can’t connect to MySQL server on ‘some-mysql’ (113)

[liran@localhost ~]$ docker run --network mysql-net --name some-mysql -e MYSQL_ROOT_PASSWORD=my-secret-pw -d mysql:latest
497ff8aa24ce904230170a51649df8eb96de638baec90ed3510ec3d420f7c7e6
[liran@localhost ~]$ docker container ls
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                 NAMES
497ff8aa24ce        mysql:latest        "docker-entrypoint.s…"   9 seconds ago       Up 8 seconds        3306/tcp, 33060/tcp   some-mysql
[liran@localhost ~]$ docker run --network mysql-net -it --rm mysql:latest mysql -hsome-mysql -uroot -p
Enter password: 
ERROR 2003 (HY000): Can't connect to MySQL server on 'some-mysql' (113)
[liran@localhost ~]$ 

@martinp999

Hi @liranye,

I copied your cli statements (with the addition of an initial docker network create mysql-net) and I got in no problems. The fact that you get asked for a password indicates that the network bridge is working fine. Did you use the correct db pswd (my-secret-pw)?

I am using docker 20.10.2, build 2291f61.

@cas--

I encountered this error while quickly trying to setup mysql. I would expect the documentation to get me up and running not:

force users to do more homework

There is little hint that users need to actually create a network so this is leaving them completely in the dark. Also by the time they come to connect with client using --network option they will need to go back destroy server container and recreate it using custom network…

I am thinking that the next step after starting the server could be an exec command to help users quickly get connected:

docker exec -it some-mysql mysql -p

Otherwise at a minimum for the client instance the wording could be improved

- connected to the `some-network` Docker network
+ connected to `some-network`, a [user-defined Docker network](https://docs.docker.com/network/network-tutorial-standalone/#use-user-defined-bridge-networks)).

Labels

question

Usability question, not directly related to an error with the image

ОШИБКА 2003 (HY000): не удается подключиться к серверу MySQL на локальном хосте (10061)

Я использовал mysql 5.6.11, он обычно отказывался и показывал мне это:

2005 — Неизвестный хост сервера MySQL localhost (11001).

В настоящее время мое решение — выключить сеть, чем она вернется в нормальное состояние. Я много искал, но ответа нет. Итак, кто-нибудь знает причину?

  • Вы пытались проверить связь с локальным хостом в вашей сети?
  • Надеюсь, эта статья вам поможет: faq.webyog.com/content/23/17/en/…
  • @Himanshu Bhardwaj: Я попробую завтра, когда появится ошибка, спасибо за ответ!
  • @Sam: Спасибо за ответ, но я не нашел ответа в этой статье, еще раз спасибо.
  • 1 @cogsmos: Сегодня я нашел, вероятно, причину того случая, когда mysql не может быть подключен, зависимость другого приложения от сети также была отключена, а затем я использую 127.0.0.1 для подключения к базе данных mysql, это сработало. Думаю, это вроде как проблема с днс, но я с ней не знаком, а вы? Кстати, спасибо за помощь.

ОШИБКА 2005 (HY000): Неизвестный хост сервера MySQL ‘localhost’ (0)

изменить список имен хостов для вашей системы:

C: Windows System32 drivers etc hosts

Убедитесь, что у вас есть следующая запись:

127.0.0.1 локальный
В моем случае эта запись была 0.0.0.0 localhost, что вызвало все проблемы.

(вам может потребоваться изменить разрешение на изменение, чтобы изменить этот файл)

При этом выполняется разрешение DNS хоста localhost на IP-адрес 127.0.0.1.

  • 1 Эта проблема возникла в помощнике по миграции SQL Server для MySQL. Ваша помощь решила это! Спасибо.
  • Еще одна возможность: если у вас более одного экземпляра MySQL, а второй находится на другом порту, mysql недостаточно умен для синтаксического анализа -h 127.0.0.1:3307, поэтому вам нужно использовать —port = 3307

Я прошел через эту ошибку сегодня и сделал все, что описано выше, но у меня не получилось. Итак, я решил изучить основную проблему и вошел в корневую папку MySQL в Windows 7 и сделал следующее решение:

  1. Перейти в папку:

    C:AppServMySQL 
  2. Щелкните правой кнопкой мыши и запустите от имени администратора эти файлы:

    mysql_servicefix.bat mysql_serviceinstall.bat mysql_servicestart.bat 

Затем закройте все окно проводника и снова откройте его или очистите кеш, затем снова войдите в phpMyAdmin.

Дело такое:

 mysql connects will localhost when network is not up. mysql cannot connect when network is up. 

Вы можете попробовать следующие шаги, чтобы диагностировать и решить проблему (я предполагаю, что какая-то другая служба блокирует порт, на котором размещен mysql):

  1. Отключите сеть.
  2. Остановите службу mysql (если окна, попробуйте из окна services.msc)
  3. Подключитесь к сети.
  4. Попробуйте запустить mysql и посмотрите, правильно ли он запускается.
  5. В любом случае проверьте системные журналы, чтобы убедиться, что при запуске службы mysql нет ошибок.
  6. Если все хорошо, попробуйте подключиться.
  7. В случае неудачи попробуйте сделать telnet localhost 3306 и посмотрите, какой результат он показывает.
  8. Попробуйте изменить порт, на котором размещен mysql, по умолчанию 3306, вы можете изменить его на другой порт, который не работает.

В идеале это должно решить проблему, с которой вы столкнулись.

  • : Я последую за вашим шагом, очень надеюсь, что он решит мою проблему, спасибо за ваше время!
  • : Я последовал вашему совету, и у меня действительно была обнаружена проблема (через шаг 5), но в конце концов она не сработала. Надеюсь, вы прочитали мой пост выше, в котором я ответил на cogsmos, спасибо.
  • Вместо того, чтобы сначала использовать какой-либо сторонний клиент, я бы рекомендовал вам использовать клиент mysql, который поставляется с самим mysql, для проверки вышеуказанных тестов. Может быть, это просто клиент доставляет вам неприятности.

Tweet

Share

Link

Plus

Send

Send

Pin

  • #1

После переустановки системы начала появляться ошибка

Unknown MySQL server host 'Тут IP из databases.cfg" (2)

Данная ошибка возникает на том же сервере где и БД
До переустановки подобного не было.

Возможно где-то что-то пропустил при настройке сервера.
Может кто-то сталкивался с подобным и поможет мне решить данную проблему.

  • #2

Если на том же сервере то напиши вместо Ip 127.0.0.1 или localhost

  • #3

Если на том же сервере то напиши вместо Ip 127.0.0.1 или localhost

Да, это вариант.
Но все-же странно что возникла эта ошибка, и лучше бы ее исправить :)

  • #4

Ну а mysql ты открыл для подключения извне?

  • #5

Ну а mysql ты открыл для подключения извне?

Да, поставил bind-adress = 0.0.0.0

  • #6

Да, поставил bind-adress = 0.0.0.0

Закомменти лучше

  • #7

Вряд ли дело в этой строке, так как в старом конфиге так-же было, и подобных ошибок небыло.
Но ок, сейчас попробую
— Добавлено позже —
Закомментировал…
Теперь такое пишет:
sourcecomms.smx] Connecting to database failed: [2002]: Can’t connect to local MySQL server through socket ‘/tmp/mysql.sock’ (2)

  • #8

Вряд ли дело в этой строке, так как в старом конфиге так-же было, и подобных ошибок небыло.
Но ок, сейчас попробую
— Добавлено позже —
Закомментировал…
Теперь такое пишет:
sourcecomms.smx] Connecting to database failed: [2002]: Can’t connect to local MySQL server through socket ‘/tmp/mysql.sock’ (2)

Вместо localhost выстави IP

  • #9

Ну или «/var/run/mysqld/mysqld.sock». По крайней мере на бубунте так.

  • #10

Вместо localhost выстави IP

А в чем проблема использовать домен?
Мне кажется дело в настройке хостов или чего-то подобного.

  • #11

А в чем проблема использовать домен?
Мне кажется дело в настройке хостов или чего-то подобного.

Теперь такое пишет:
sourcecomms.smx] Connecting to database failed: [2002]: Can’t connect to local MySQL server through socket ‘/tmp/mysql.sock’ (2)

напиши вместо Ip 127.0.0.1

— Добавлено позже —
А вообще возможно не хватает библиотек.
и ОС какая?
Я с Deb8 мучался, с такой же ошибкой (или похожей), откатился на деб7 и всё прошло

  • #12

— Добавлено позже —
А вообще возможно не хватает библиотек.
и ОС какая?
Я с Deb8 мучался, с такой же ошибкой (или похожей), откатился на деб7 и всё прошло

Ось та-же что и была…
Ubuntu 15.04 если не ошибаюсь.

  • #14

@T1MOXA, apt-get install lib32z1 попробуй

lib32z1 is already the newest version.
— Добавлено позже —
Проблема решена!
Я сам не знаю как именно, но пока я исправлял другие ошибки, и до настраивал сервер ошибка исчезла сама собой!

Последнее редактирование: 21 Ноя 2016

524 votes

4 answers

Get the solution ↓↓↓

I was using mysql 5.6.11,it usually turned down and show me this:

2005 — Unknown MySQL server host ‘localhost'(11001).

Currently my resolution is to turn off the network,than it return to normal.I had searched a lot,but no answer is revalent to it.So,does anyone knows the reason?

2022-06-6

Write your answer


305

votes

Answer

Solution:

ERROR 2005 (HY000): Unknown MySQL server host ‘localhost’ (0)

modify list of host names for your system:

C:WindowsSystem32driversetchosts

Make sure that you have the following entry:

127.0.0.1 localhost
In my case that entry was 0.0.0.0 localhost which caussed all problem

(you may need to change modify permission to modify this file)

This performs DNS resolution of host “localhost” to the IP address 127.0.0.1.


642

votes

Answer

Solution:

I have passed through that error today and did everything described above but didn’t work for me. So I decided to view the core problem and logged onto the MySQL root folder in Windows 7 and did this solution:

  1. Go to folder:

    C:AppServMySQL
    
  2. Right click and Run as Administrator these files:

    mysql_servicefix.bat
    
    mysql_serviceinstall.bat
    
    mysql_servicestart.bat
    

Then close the entire explorer window and reopen it or clear cache then login to phpMyAdmin again.


800

votes

Answer

Solution:

The case is like :

 mysql connects will localhost when network is not up.
 mysql cannot connect when network is up.

You can try the following steps to diagnose and resolve the issue (my guess is that some other service is blocking port on which mysql is hosted):

  1. Disconnect the network.
  2. Stop mysql service (if windows, try from services.msc window)
  3. Connect to network.
  4. Try to start the mysql and see if it starts correctly.
  5. Check for system logs anyways to be sure that there is no error in starting mysql service.
  6. If all goes well try connecting.
  7. If fails, try to do a telnet localhost 3306 and see what output it shows.
  8. Try changing the port on which mysql is hosted, default 3306, you can change to some other port which is ununsed.

This should ideally resolve the issue you are facing.


579

votes

Answer

Solution:

Follow these steps to fix this error
Use connect [email protected] instead of connect [email protected]

if it doesn’t work then go to C:WindowsSystem32driversetchosts and check the IP address attached to host name.
use that IP, so it will be.
connect [email protected]_ip_address_you_found


Share solution ↓

Additional Information:

Date the issue was resolved:

2022-06-6

Link To Source

Link To Answer
People are also looking for solutions of the problem: you must enable the openssl extension in your php.ini to load information from https://repo.packagist.org

Didn’t find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.


Similar questions

Find the answer in similar questions on our website.

In mysql server, when importing the sql file into the db. I am getting as error as below. So, can you help where the issues lies that is in mysql server config or the sql file

ERROR 2005 (HY000) at line 1: Unknown MySQL server host ‘Courier’ (1)

Mysql Server Version : 5.0.45

asked Feb 24, 2012 at 13:23

Mughil's user avatar

2

This is a name resolution issue. The machine you’re using to import this sql file is not able to resolve the MySQL Server hostname ‘Courier’.

Are you sure this is the correct hostname? Can you provide the output of a ‘nslookup Courier’ and the command you’re using to import?

If you’re not sure about the hostname, try importing using the MySQL Server ip address.

Hope this helps.

answered Feb 24, 2012 at 14:01

Luis Fernando Alen's user avatar

I was using mysql 5.6.11,it usually turned down and show me this:

2005 — Unknown MySQL server host ‘localhost'(11001).

Currently my resolution is to turn off the network,than it return to normal.I had searched a lot,but no answer is revalent to it.So,does anyone knows the reason?

Shadow's user avatar

Shadow

33.3k10 gold badges52 silver badges62 bronze badges

asked May 16, 2013 at 6:24

user2388626's user avatar

9

ERROR 2005 (HY000): Unknown MySQL server host ‘localhost’ (0)

modify list of host names for your system:

C:WindowsSystem32driversetchosts

Make sure that you have the following entry:

127.0.0.1 localhost
In my case that entry was 0.0.0.0 localhost which caussed all problem

(you may need to change modify permission to modify this file)

This performs DNS resolution of host “localhost” to the IP address 127.0.0.1.

answered Jul 30, 2013 at 13:52

GaneshP's user avatar

GaneshPGaneshP

7367 silver badges25 bronze badges

3

I have passed through that error today and did everything described above but didn’t work for me. So I decided to view the core problem and logged onto the MySQL root folder in Windows 7 and did this solution:

  1. Go to folder:

    C:AppServMySQL
    
  2. Right click and Run as Administrator these files:

    mysql_servicefix.bat
    
    mysql_serviceinstall.bat
    
    mysql_servicestart.bat
    

Then close the entire explorer window and reopen it or clear cache then login to phpMyAdmin again.

Mogsdad's user avatar

Mogsdad

44.3k21 gold badges151 silver badges272 bronze badges

answered Dec 2, 2015 at 19:22

Mizo Games's user avatar

Mizo GamesMizo Games

1791 silver badge8 bronze badges

The case is like :

 mysql connects will localhost when network is not up.
 mysql cannot connect when network is up.

You can try the following steps to diagnose and resolve the issue (my guess is that some other service is blocking port on which mysql is hosted):

  1. Disconnect the network.
  2. Stop mysql service (if windows, try from services.msc window)
  3. Connect to network.
  4. Try to start the mysql and see if it starts correctly.
  5. Check for system logs anyways to be sure that there is no error in starting mysql service.
  6. If all goes well try connecting.
  7. If fails, try to do a telnet localhost 3306 and see what output it shows.
  8. Try changing the port on which mysql is hosted, default 3306, you can change to some other port which is ununsed.

This should ideally resolve the issue you are facing.

Derlin's user avatar

Derlin

9,4642 gold badges29 silver badges52 bronze badges

answered May 17, 2013 at 3:44

Himanshu Bhardwaj's user avatar

3

Follow these steps to fix this error
Use connect root@127.0.0.1 instead of connect root@localhost

if it doesn’t work then go to C:WindowsSystem32driversetchosts and check the IP address attached to host name.
use that IP, so it will be.
connect root@the_ip_address_you_found

answered Apr 29, 2021 at 11:39

sule mohammed's user avatar

401 votes

4 answers

Get the solution ↓↓↓

I was using mysql 5.6.11,it usually turned down and show me this:

2005 — Unknown MySQL server host ‘localhost'(11001).

Currently my resolution is to turn off the network,than it return to normal.I had searched a lot,but no answer is revalent to it.So,does anyone knows the reason?

2022-06-6

Write your answer


440

votes

Answer

Solution:

ERROR 2005 (HY000): Unknown MySQL server host ‘localhost’ (0)

modify list of host names for your system:

C:WindowsSystem32driversetchosts

Make sure that you have the following entry:

127.0.0.1 localhost
In my case that entry was 0.0.0.0 localhost which caussed all problem

(you may need to change modify permission to modify this file)

This performs DNS resolution of host “localhost” to the IP address 127.0.0.1.


630

votes

Answer

Solution:

I have passed through that error today and did everything described above but didn’t work for me. So I decided to view the core problem and logged onto the MySQL root folder in Windows 7 and did this solution:

  1. Go to folder:

    C:AppServMySQL
    
  2. Right click and Run as Administrator these files:

    mysql_servicefix.bat
    
    mysql_serviceinstall.bat
    
    mysql_servicestart.bat
    

Then close the entire explorer window and reopen it or clear cache then login to phpMyAdmin again.


121

votes

Answer

Solution:

The case is like :

 mysql connects will localhost when network is not up.
 mysql cannot connect when network is up.

You can try the following steps to diagnose and resolve the issue (my guess is that some other service is blocking port on which mysql is hosted):

  1. Disconnect the network.
  2. Stop mysql service (if windows, try from services.msc window)
  3. Connect to network.
  4. Try to start the mysql and see if it starts correctly.
  5. Check for system logs anyways to be sure that there is no error in starting mysql service.
  6. If all goes well try connecting.
  7. If fails, try to do a telnet localhost 3306 and see what output it shows.
  8. Try changing the port on which mysql is hosted, default 3306, you can change to some other port which is ununsed.

This should ideally resolve the issue you are facing.


567

votes

Answer

Solution:

Follow these steps to fix this error
Use connect [email protected] instead of connect [email protected]

if it doesn’t work then go to C:WindowsSystem32driversetchosts and check the IP address attached to host name.
use that IP, so it will be.
connect [email protected]_ip_address_you_found


Share solution ↓

Additional Information:

Date the issue was resolved:

2022-06-6

Link To Source

Link To Answer
People are also looking for solutions of the problem: port 80 in use by «unable to open process» with pid 4!

Didn’t find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.


Similar questions

Find the answer in similar questions on our website.

for -h the ip_address:port format you’re using is invalid, you want to use a -P option for specifying the port (for localhost this isn’t necessary).

And the way Docker remaps the port such as with your 8003:3306 is <host_port>:<container_port> so the container doesn’t undergo any changes, but the host will forward anything on 8003 to the container on 3306. But for other containers on the same Docker network they will all still use the standard ports for their respective apps when communicating with eachother

$ docker-compose up -d
Creating veto_db ... done

$ docker exec -it veto_db mysql -h127.0.0.1 -P3306 -uusername -ppassword -Ddatabasename
Welcome to the MariaDB monitor.  Commands end with ; or g.
Your MariaDB connection id is 8
Server version: 10.3.14-MariaDB-1:10.3.14+maria~bionic mariadb.org binary distribution

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.

MariaDB [databasename]>

AWS RDS Unknown MySQL Server Host error causing trouble? Read on to resolve this issue. 

At Bobcares, we offer solutions for every query, big and small, as a part of our AWS Support Services.

Let’s take a look at how our AWS Support Team is ready to help customers resolve Unknown MySQL Server Host error.

What is AWS RDS: “Unknown MySQL Server Host” error?

Every now and then, our customers come across the “Unknown MySQL Server Host” error in AWS RDS. According to our MySQL Server experts, this error is due to internal name servers in AWS. Rather than return an IP address, they time out or return an empty answer resulting in the error. In other words. The “Unknown MySQL Server Host” error message pops up due to hostup lookup fails.

AWS RDS: Unknown MySQL Server Host error

Fortunately, our experts have come up with a solution to resolve Unknown MySQL Server Host” error.

How to resolve Unknown MySQL Server Host error

First, use the PHP function gethostbyname() to access the IP address from the DNS name as seen here:


Alternatively, here is another solution to the Unknown MySQL Server Host error:

  1. To begin with, verify the RDS instance’s endpoint is correct. If it is incorrect, it may be due to one of the following reasons:
    • Invalid endpoint format
    • Manually releasing a public endpoint
    • Endpoint exceeds maximum length
  2. If the endpoint is correct, we have to try changing the DNS server IP addresses as seen here:
    • If we connect to the RDS instance through the classic network change the DNS server IP addresses to 10.143.22.118 and 10.143.22.116.
    • In case we connect to the RDS instance through an internal network by changing the DNS server IP addresses to 100.100.2.138 and 100.100.2.136.
    • If we connect to the RDS instance through the Internet, change the DNS server IP addresses to 223.6.6.6 and 223.5.5.5.

[Need assistance with another query? We are available 24/7.]

Conclusion

In a nutshell, our skilled AWS Support Engineers at Bobcares demonstrated how to resolve the RDS Unknown MySQL Server Host error.

PREVENT YOUR SERVER FROM CRASHING!

Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

GET STARTED

In case you encounter this error with mysql and your docker-compose setup:

Unknown MySQL server host <mysql-service-name>Code language: HTML, XML (xml)

… and you dont know why because everything seems to be correct.

Then you might have an upgrade problem with mysql because you are reusing an old volume that was created for another mysql version.
This can happen when you use a unspecified tag as mysql:latest (not recommended anyway) and there was a version bump in the official mysql image.
Or you upgraded the mysql container yourself, f.e. from mysql:5.6 to mysql:5.7 and you are reusing the data volume with the mysql files.

When you check the startup logs you might see that mysql container is shutting down after startup because of an error like this:

Can't open the mysql.plugin table. Please run mysql_upgrade to create it.

You can run the upgrade command in the container:

docker exec -it mysql_container_name bash -c "mysql_upgrade -uroot -proot"Code language: JavaScript (javascript)

Or simply delete the volume and recreate it.
Note: the data will unfortunatly be lost. So better dump the data before deleting the volume and reimport it.
In my case its no problem because im starting a new project anyway.

To delete the volume you can:

docker volume rm <volume id>Code language: HTML, XML (xml)

Or just delete the data dir:

rm -rf ./data/mysql

Then restart your setup so the mysql container recreates the databases:

docker-compose up

and mysql is working again and the application is able to connect. :)

In mysql server, when importing the sql file into the db. I am getting as error as below. So, can you help where the issues lies that is in mysql server config or the sql file

ERROR 2005 (HY000) at line 1: Unknown MySQL server host ‘Courier’ (1)

Mysql Server Version : 5.0.45

asked Feb 24, 2012 at 13:23

Mughil's user avatar

2

This is a name resolution issue. The machine you’re using to import this sql file is not able to resolve the MySQL Server hostname ‘Courier’.

Are you sure this is the correct hostname? Can you provide the output of a ‘nslookup Courier’ and the command you’re using to import?

If you’re not sure about the hostname, try importing using the MySQL Server ip address.

Hope this helps.

answered Feb 24, 2012 at 14:01

Luis Fernando Alen's user avatar

  • #1

После переустановки системы начала появляться ошибка

Unknown MySQL server host 'Тут IP из databases.cfg" (2)

Данная ошибка возникает на том же сервере где и БД
До переустановки подобного не было.

Возможно где-то что-то пропустил при настройке сервера.
Может кто-то сталкивался с подобным и поможет мне решить данную проблему.

  • #2

Если на том же сервере то напиши вместо Ip 127.0.0.1 или localhost

  • #3

Если на том же сервере то напиши вместо Ip 127.0.0.1 или localhost

Да, это вариант.
Но все-же странно что возникла эта ошибка, и лучше бы ее исправить :)

  • #4

Ну а mysql ты открыл для подключения извне?

  • #5

Ну а mysql ты открыл для подключения извне?

Да, поставил bind-adress = 0.0.0.0

  • #6

Да, поставил bind-adress = 0.0.0.0

Закомменти лучше

  • #7

Вряд ли дело в этой строке, так как в старом конфиге так-же было, и подобных ошибок небыло.
Но ок, сейчас попробую
— Добавлено позже —
Закомментировал…
Теперь такое пишет:
sourcecomms.smx] Connecting to database failed: [2002]: Can’t connect to local MySQL server through socket ‘/tmp/mysql.sock’ (2)

  • #8

Вряд ли дело в этой строке, так как в старом конфиге так-же было, и подобных ошибок небыло.
Но ок, сейчас попробую
— Добавлено позже —
Закомментировал…
Теперь такое пишет:
sourcecomms.smx] Connecting to database failed: [2002]: Can’t connect to local MySQL server through socket ‘/tmp/mysql.sock’ (2)

Вместо localhost выстави IP

  • #9

Ну или «/var/run/mysqld/mysqld.sock». По крайней мере на бубунте так.

  • #10

Вместо localhost выстави IP

А в чем проблема использовать домен?
Мне кажется дело в настройке хостов или чего-то подобного.

  • #11

А в чем проблема использовать домен?
Мне кажется дело в настройке хостов или чего-то подобного.

Теперь такое пишет:
sourcecomms.smx] Connecting to database failed: [2002]: Can’t connect to local MySQL server through socket ‘/tmp/mysql.sock’ (2)

напиши вместо Ip 127.0.0.1

— Добавлено позже —
А вообще возможно не хватает библиотек.
и ОС какая?
Я с Deb8 мучался, с такой же ошибкой (или похожей), откатился на деб7 и всё прошло

  • #12

— Добавлено позже —
А вообще возможно не хватает библиотек.
и ОС какая?
Я с Deb8 мучался, с такой же ошибкой (или похожей), откатился на деб7 и всё прошло

Ось та-же что и была…
Ubuntu 15.04 если не ошибаюсь.

  • #14

@T1MOXA, apt-get install lib32z1 попробуй

lib32z1 is already the newest version.
— Добавлено позже —
Проблема решена!
Я сам не знаю как именно, но пока я исправлял другие ошибки, и до настраивал сервер ошибка исчезла сама собой!

Последнее редактирование: 21 Ноя 2016

Понравилась статья? Поделить с друзьями:
  • Unknown file version fortniteclient win64 shipping exe ошибка
  • Unknown device ошибка что это
  • Unknown device ошибка код 43 как исправить ошибку
  • Unknown device код 43 ошибка usb устранить
  • Unknown device код 43 как исправить ошибку usb