Laravel php artisan mysql connection refused

docker
mysql
2.0

#1

Hi, I’m getting the laravel migrations failed problem.

[PDOException]
SQLSTATE[HY000] [2002] Connection refused

I have a custom private docker image. It builds fine on my mac locally. I can’t seem to figure out how to get the logs to display in Circleci after these commands fail (I have an install script.)

I have tried the localhost stuff.

Is there a chance that circleci is overruling my mysql user name? I can’t see how it could in the remote docker execution environment.

What other info is needed to troubleshoot this? (P.S. - I also can’t build locally - due to the remote docker needs of the local circleCI build tool)

Something seems to possibly smell funny with MySQL not starting. I wonder how to check that out.


#2

Might be related to Prevent race conditions by waiting for services with Dockerize


#3

trying that out. I saw that post before and I wasn’t sure if I could run my setup script in my own environment why this would behave different.

Also - it’s really not clear what technique I should use to determine if it is mysql, or something else.


#4

You need to specify 127.0.0.1 as the host so MySQL uses TCP. If you have a config, you’ll need to update that. We only expose port 3306 not the socket file. Also, be sure to load MySQL as an image with the necessary env vars:

https://hub.docker.com/r/mysql/mysql-server

EDIT: I recommend using one of our convenience images as it has performance tweaks included: https://hub.docker.com/r/circleci/mysql/tags/

You can find the tweaks in this repo: https://github.com/circleci/circleci-images/tree/master/mysql/resources


Setting up mysql 5.7 environment variables - Access denied for user (Laravel project)
#5