Skip to content
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

Can't connect to local MySQL server #13

Closed
leymannx opened this issue Jan 9, 2018 · 6 comments
Closed

Can't connect to local MySQL server #13

leymannx opened this issue Jan 9, 2018 · 6 comments
Assignees
Labels

Comments

@leymannx
Copy link

leymannx commented Jan 9, 2018

I tried to install Drupal from a fresh clone but when it comes to DB credentials it fails:

Failed to connect to your database server. The server reports the following message: SQLSTATE[HY000] [2002] No such file or directory.

Steps performed

  • $ git clone https://github.com/keopx/docker-lamp keopx
  • $ cd keopx/data
  • $ rm -rf www
  • $ drush dl (local Drush on my Mac)
  • $ mv drupal-8.4.4 www
  • $ docker-compose up -d
  • everything fine, no error
  • Browser: http:https://localhost:8008
  • run installation routine
  • then stops on DB connection (UN: drupaluser, PW: drupalpass, DB: drupal) with above error

I then tried

  • $ docker exec -ti keopx_web_1 bash
  • inside I tried: $ mysql -uroot -proot
  • Follwing error:

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2 "No such file or directory")

Do have to perform anything extra before the MySQL container is available to the web container?

@leymannx
Copy link
Author

leymannx commented Jan 9, 2018

Whereas PHPMyAdmin and the MySQL container itself both run just fine.

@keopx
Copy link
Owner

keopx commented Jan 9, 2018

@leymannx the container that has MySQL is keopx_mysql_1.

If you connect remotly $ mysql -hmysql -uroot -proot from any docker container (e.i. keopx_web_1)

@leymannx another thing, when you connect Drupal to MySQL, use mysql instead localhost

@keopx keopx closed this as completed Jan 9, 2018
@keopx keopx self-assigned this Jan 9, 2018
@keopx keopx added the question label Jan 9, 2018
@leymannx
Copy link
Author

leymannx commented Jan 9, 2018

screenshot 2018-01-09 15 02 26

@leymannx
Copy link
Author

leymannx commented Jan 9, 2018

Thanks a lot! That did the trick.

@keopx
Copy link
Owner

keopx commented Jan 9, 2018

@leymannx Docker resolve internally docker name as hostname

@leymannx
Copy link
Author

leymannx commented Jan 9, 2018

That was the point I missed. Thanks a lot again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants