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 MySQL Using Docker #114

Closed
asithade opened this issue Jun 14, 2017 · 5 comments
Closed

Can't Connect to MySQL Using Docker #114

asithade opened this issue Jun 14, 2017 · 5 comments

Comments

@asithade
Copy link

asithade commented Jun 14, 2017

Been trying to figure out what's going on but when I try to setup the site using sudo docker-compose up --build it goes through fine all the way until here:

app_1  | #<Mysql2::Error: Can't connect to MySQL server on '127.0.0.1' (111)>
app_1  | Couldn't create database for {"adapter"=>"mysql2", "encoding"=>"utf8", "database"=>"phantom_dc", "username"=>"xxx", "password"=>"xxx", "host"=>"127.0.0.1", "pool"=>100, "port"=>"3306"}, charset: utf8, collation: utf8_unicode_ci

I've tested the username and password and it connects to MySQL fine. Prior to that, the db_1 looks like it was able to connect to MySQL too.

db_1   | 2017-06-14T23:05:08.365715Z 0 [Note] mysqld: ready for connections.
db_1   | Version: '5.7.18'  socket: '/var/run/mysqld/mysqld.sock'  port: 3306  MySQL Community Server (GPL)

Is there something I'm missing here?

@asithade asithade changed the title Can't Connec to MySQL Using Docker Can't Connect to MySQL Using Docker Jun 14, 2017
@wioux
Copy link
Member

wioux commented Jun 20, 2017

Make sure this environment variable is set in the app container: MYSQL_HOST=db. It's recommended to start development by creating a .env file with the initial values in .env.example.

@mr-sk
Copy link

mr-sk commented Jun 21, 2017

Hello,

My .env has MYSQL_HOST=db in my .env and when I run sudo docker-compose up --build I get:

db_1 | 2017-06-21T14:27:52.538551Z 4 [Note] Aborted connection 4 to db: 'phantom_dc_development' user: 'phantom_dc' host: '172.18.0.3' (Got an error reading communication packets)

So, also having the same error.

@wioux
Copy link
Member

wioux commented Jun 21, 2017

Hi @mr-sk. This is a separate thing, as in your case the app has connected to the db instance but then that connection breaks, while @asithade's app container is not connecting to the db server at all. If you're having problems can you open a separate issue? Be sure to include the app container's output as well around the time of the error.

Thanks,
Peter

@asithade
Copy link
Author

Hi there,

I actually get the same error as him when I set it to db.

@wioux
Copy link
Member

wioux commented Jun 21, 2017

That line will pop up occasionally during a normal boot of the app. Closing this issue for now, but please open another one if you have other problems.

@wioux wioux closed this as completed Jun 21, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants