Error 2005 hy000 unknown mysql server host

The issue When trying to connect to a mariadb container either manually or via shell script using mysql -h'127.0.0.1:8003 -uusername -ppassword -ndatabasename (It does not matter weather I use ...

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]>

Содержание

  1. ERROR 2005 (HY000): Unknown MySQL server host #240
  2. Comments
  3. The issue
  4. Setup
  5. Footer
  6. ERROR 2005 (HY000): Unknown MySQL server host ‘some-mysql’ (0) #644
  7. Comments
  8. Local installation: Unknown MySQL server host #51
  9. Comments
  10. Drupal Русскоязычное сообщество
  11. Главные вкладки
  12. Комментарии

ERROR 2005 (HY000): Unknown MySQL server host #240

The issue

When trying to connect to a mariadb container either manually or via shell script using
mysql -h’127.0.0.1:8003 -uusername -ppassword -ndatabasename

(It does not matter weather I use 127.0.0.1 or localhost.)

I get the following error

ERROR 2005 (HY000): Unknown MySQL server host ‘127.0.0.1:8003’

When I try to connect to the same mariadb server using MysqlWorkbench it works just fine, though.

Setup

I am using the mariadb container as part of a docker compose environment (running on MInt)

The mariadb container is setup as follows:

My /etc/hosts file entry concerning the localhost
127.0.0.1 localhost
127.0.0.1 FQDN of dev site 1
127.0.0.1 FQDN of dev site 2
etc.

I need these DNS entries since I am using a nginx reverse proxy to have my development sites accessible via https and their FQDN. No idea if that is really relevant, though.

The text was updated successfully, but these errors were encountered:

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 : 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

though I am a bit ashamed both about the invalid usage of the «-h» flag and not simply using the docker «exec» command . I am still very thankful. You helped me out a lot.

© 2023 GitHub, Inc.

You can’t perform that action at this time.

You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.

Источник

ERROR 2005 (HY000): Unknown MySQL server host ‘some-mysql’ (0) #644

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

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?

The text was updated successfully, but these errors were encountered:

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.

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

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

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

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
    «

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

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

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
using your advice I still get the following error:
ERROR 2003 (HY000): Can’t connect to MySQL server on ‘some-mysql’ (113)

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 .

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:

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

Источник

Local installation: Unknown MySQL server host #51

Then I run ./psh.phar install as suggested in the guide for local installation, an error occurs:

This is due to the -h ‘mysql’ option for the mysql command at step 3/28.

I fixed the error by registering 127.0.0.1 mysql in /etc/hosts . Maybe this information should be added to the installation guide?

The text was updated successfully, but these errors were encountered:

I guess you did a local installation. So you had to run ./bin/setup first. Where you can define the credentials

Yes, but the database host in the setup defaults to localhost , not mysql .

Well, but this does not work with the Docker containers where app_mysql is built.
Because if we ssh into it, the composer taks fails due to the missing CA certificate file.

So in both cases the default setup does not directly work.
I guess we need at least some changes for the Docker images. At least when we want to follow the steps from the repository.

To sum it up:
The default value for the DB host is mysql , by running ./bin/setup you can override this default.
In the setup script we use localhost as the default, because when you run the setup script you problably want to install it locally, note that this will also just override the mysql for the DB Host.
You can find more information about how this overriding of config values works here.

@DanielRuf i haven’t seen that error message.
What steps did you take?
Did run the ./bin/setup script before starting the docker container?
You don’t need to because the default config values we provide directly work with our docker-setup.

Lastly did you run the ./psh.phar install command inside the container or on your local system?
Maybe the installation guide in the readme can be misleading here, but you need to run the install command inside your container.

Did run the ./bin/setup script before starting the docker container?

Lastly did you run the ./psh.phar install command inside the container or on your local system?

Inside. I did not run any other .bin/setup as this is not mentioned there.
If this is needed it should be added to the docs.

Not sure but it did not find the mysql instance by default.

You can see in the docker-compose file the app_mysql container is linked to the app container with the name mysql , so the DB host seen from the app container is mysql . https://github.com/shopware/development/blob/18ca00ac721fbc271b60645a3fa9304810820567/docker-compose.yml#L7

Did run the ./bin/setup script before starting the docker container?

If the psh.phar install task does this, yes:

You don’t have to run the ./psh.phar install command before starting the container.
If you use the docker setup all psh commands you may need to run on your local machine are prefixed with docker: .
E.g.
./psh.phar docker:start
./psh.phar docker:ssh
./psh.phar docker:stop

I tried this in the container, was the same result.
Not 100% sure as it was failing with the given steps in the docs — there might be something unclear.

I guess your problem has been fixed? Feel free to reopen this issue if it’s not.

Источник

Drupal Русскоязычное сообщество

Главные вкладки

Доброе утро.
Вот такая ошибочка: PDOException: SQLSTATE[HY000] [2005] Unknown MySQL server host

как правильно заполнить файл settings.php?

где у меня здесь ошибка?!
Помогите люди добрые

  • Блог
  • Войдите или зарегистрируйтесь, чтобы отправлять комментарии

Комментарии

подскажите где я ошиблась или я Вас не правильно поняла

Эти все строки установить как на новом хостинге работает подключение к базе данных

«’database’ => ‘mybase123’,
‘username’ => ‘iroot’,
‘password’ => ‘pass’,
‘host’ => ‘http://1.mybase.com.ua’,»
Эти все строки установить как на новом хостинге работает подключение к базе данных

PDOException: SQLSTATE[HY000] [2005] Unknown MySQL server host ‘http://1.mybase.com.ua/’ (12) in lock_may_be_available() (line 167 of /var/www/iroot/data/www/1.mybase.com.ua/includes/lock.inc).

заменить на
$databases = array (
‘default’ =>
array (
‘default’ =>
array (
‘database’ => ‘mybase123’,
‘username’ => ‘iroot’,
‘password’ => ‘pass’,
‘host’ => ‘localhost’,
‘port’ => »,
‘driver’ => ‘mysql’,
‘prefix’ => »,
),
),
);

PDOException: SQLSTATE[28000] [1045] Access denied for user ‘mybase123’@’localhost’ (using password: YES) in lock_may_be_available() (line 167 of /var/www/iroot/data/www1.mybase.com.ua/includes/lock.inc).

это при ‘host’ => ‘localhost’,

ну тут уж вопрос к хосту, обращайтесь в тех.поддержку. Ошибка в юзере, пароле, дб_имени

вот тут глупая мысль в голову пришла. А Вы базу создавали, юзера добавляли, данные импортировали?

вот тут глупая мысль в голову пришла. А Вы базу создавали, юзера добавляли, данные импортировали?

базу создала, юзера добавила, данные импортировала
(Мучусь уже второй день)
Началось с того что не смогла установить drupal 7.24 на хостинг. (на данном хостинге техподдержка только на бумаге)- ответа уже 5 день жду!

если у Вас есть drupal 7.24 с подправленными файлами php.ini и htaccess — то сбросьте пожалуйста
(одни пишут одно другие другое. я вроде и то правила и это. — не помогло)

потом уж решила переносить. (как видете пока безуспешно)

сейчас думаю установить на локальный хостинг, чистый друпал и попытаться перенести без наполнения.

если бы я смогла установить сразу же на хостинг. (я бы не парилась)

спасибо за Отзывчивость.

а Можно ли Установить Drupal c привязкой уже к внешней базе данных?!
а потом просто перекинуть файлы на хостинг?!

можно. Просто тут ‘host’ => ‘localhost’, вместо локалхост пишете айпи сервера с базой. При необходимости ещё и порт. Но Вам это не нужно. Зайдите в базу через Phpmyadmin и перепроверте имя пользователя, пароль и название базы.

Не создавайте однотипные топики, будем помогать тут как сможем. У Вас конкретная проблема с ошибкой в юзере, пароле и названии базы. Суть в том, что бы при переносе изменить в settings.php юзера, пароль и базу на новые значения, которые будут совпадать со значениями в новой базе. У Вас пока не совпадают, про что Вам сайт и написал

Access denied for user

Просто тут ‘host’ => ‘localhost’,

‘database’ => ‘mybase123’,
‘username’ => ‘iroot’,
‘password’ => ‘pass’,
‘host’ => ‘localhost’,

и сейчас главное перепроверить имя базы данных, пользователя и пароль

посмотрите пожалуйста на приложенный файл (там расписано кое-что но не могу понять как это применить к файлу settings.php
===
base_url — не могу понять куда конкретно нужно вписывать путь к базе данных
сейчас устанавливаю drupal на поддомен, а ссылку нужно указывать на главный домен, иль поддомен или просто IP

а Можно ли Установить локально Drupal c привязкой уже к внешней базе данных?!

Источник

One: Problem description
[root @ localhost mytop 1.6] #/usr/local/webserver/mysql/bin/mysql -u admin – p12345678 – h 172.29.141.112:3306 – e “show databases;”
ERROR 2005 (HY000): Unknown MySQL server host ‘172.29.141.112:3306’ (0)
[[email protected] mytop-1.6]#

 
Two: Problem solving
[root @ localhost mytop 1.6] #/usr/local/webserver/mysql/bin/mysql -u admin – p12345678 172.29.141.112 – P – 3306 – h e “show databases;”
+ — — — — — — — — — — — — — — — — — — — — +
| Database |
+ — — — — — — — — — — — — — — — — — — — — +
| information_schema |
| | blog
| mysql |
| performance_schema |
| Test |
+ — — — — — — — — — — — — — — — — — — — — +
[root @ localhost mytop 1.6] #

 
Three: The problem
Mysql didn’t support mysql-H IP :port. You might have thought something was wrong, but if you thought about it at the time, you would have found it. You would have posted it on the iptub.

 
Four: Other reasons
Firewall issues, /etc/init.d/iptables stop off, or reset

Read More:

896 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


427

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.


896

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.


468

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.


27

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: target class [commandmakecommand] does not exist.

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.

  • Remove From My Forums
  • Question

  • Cannot connect to MySQL Server, Firewall port 3306 opened, IP address added and get:  ERROR 2005 (HY000): Unknown MySQL server host

    I have no issues connecting with my MS SQL Server instance in Azure, just MySQL is failing to connect using Azure powershell: mysql -h<server>.mysql.database.azure.com -<adminusername>@<server> -p<mypassword>I’ve

    I’ve tried mysql workbench too, no luck.

    Help!

Answers

  • Hey,

    Found the problem but I needed to reset the password to something simple, eg: Someword99

    My complex password failed, which isn’t good lol

    Cheers

    • Marked as answer by

      Monday, January 27, 2020 3:37 AM

Понравилась статья? Поделить с друзьями:

Читайте также:

  • Error 2002 webasyst
  • Error 1872 the document has no document element on line 1 перевод
  • Error 1872 hy000 slave failed to initialize relay log info structure from the repository
  • Error 186 hdc overflow mimaki
  • Error 2002 hy000 can t connect to local mysql server through socket tmp mysql sock

  • 0 0 голоса
    Рейтинг статьи
    Подписаться
    Уведомить о
    guest

    0 комментариев
    Старые
    Новые Популярные
    Межтекстовые Отзывы
    Посмотреть все комментарии