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

MySQL connection failed #59

Closed
alex-sorochkin opened this issue May 1, 2017 · 5 comments
Closed

MySQL connection failed #59

alex-sorochkin opened this issue May 1, 2017 · 5 comments
Labels

Comments

@alex-sorochkin
Copy link

Hello!
I'm starting a new project using symfony and your containers. But I face with this error on establishing the MySQL connection: SQLSTATE[HY000] [2002] Connection refused

I googled this issue and they suggest to use localhost instead of 127.0.0.1 as a host. If I change this I get another error: SQLSTATE[HY000] [2002] No such file or directory.

I spent all the day trying to find the solution, but still no result. I tried all the combinations of hosts, ports, database name, also different usernames (root and user) - no result.

If I try to connest MySQL from command line - this works fine.

Not to have any config issues I was trying to create connection directly:
$conn = new \PDO('mysql:dbname=mydb;host=localhost;charset=UTF8;unix_socket=/var/run/mysqld/mysqld.sock', 'user', 'userpass'); - so I'm sure this is just connection issue, but not a symfony problem. I just tried to use socket as the guys recommended in StackOverflow.

Do you have any ideas how to sort this?
Thanks, Alex.

@maxpou
Copy link
Owner

maxpou commented May 1, 2017

Hi @alex-sorochkin,
the host seems to be wrong. You cannot connect to 127.0.0.1 from another container.
In the setup guide, the step 4.1 indicate the correct host: db (instead of localhost/127.0.0.1)

cheers

@maxpou maxpou added the question label May 1, 2017
@11mb
Copy link

11mb commented May 2, 2017

I have the same problem. The correct host is 'db' indeed, but in my case the database container isn't up. When I do a 'docker ps' I get only:

  • elk
  • nginx
  • php

When doing docker-compose up:

db_1 | chown: changing ownership of '/var/lib/mysql/': Operation not permitted
maxpou_db_1 exited with code 1

this is on an osx host system

@alex-sorochkin
Copy link
Author

Thanks a lot!!! It works now!
Seems I missed it during the installation, and forgot when returned again.

@maxpou
Copy link
Owner

maxpou commented May 2, 2017

Good news 😉

@11mb : please open another issue and don't forget to provide more details (i.e. configuration files, docker info...)

@11mb
Copy link

11mb commented May 4, 2017

Hi Maxpou, thx for your work on this repo and your feedback! I opened a new issue #60. I found a walk-around by using a volume in docker-compose.yml.

@maxpou maxpou closed this as completed May 4, 2017
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

3 participants