An exception occurred in driver: SQLSTATE[HY000] [2002] Connection refused
Did you try to use the internal identifier as mysql host?
DATABASE_URL=mysql://root:root@symfony_mysql:3306/s4DATABASE_URL=mysql://root:root@mysql:3306/s4
I don't think 127.0.0.1 works from within the container.
You also could try to use your 'external' IP or URL, as you have exposed port 3306 already.
You’re trying to connect to root:root
, but your user is sf4
. Try:
DATABASE_URL=mysql://sf4:sf4@127.0.0.1:3306/s4
Also try connecting from the command line, to make sure that it is actually working.
Edit: Just realised that Connection refused
is normally when it’s not running, not a user/password error. Check that MySQL is running.
use this command to get the ip adress
docker inspect mysql | grep IPAddress
then for example:
DATABASE_URL=mysql://root:@the ip adress:3306/dbname?serverVersion=5.7DATABASE_URL=mysql://root:@172.17.0.3:3306/test?serverVersion=5.7
or instead of the the ip adress make the name of the container