Doesnt connect to db

I have a cluster of 3 mysql 5.7 db and there is MySQLrouter to connect to it.
I can connect to it via MySQL command and MySQLSH through the router; however, after bringing the docker up, it doesn’t connect to db through router.

cms-web_1 | Waiting for MySQL to start - max 300 seconds
cms-web_1 | MySQL started
cms-web_1 | Updating settings.php
cms-web_1 | ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/run/mysqld/mysqld.sock’ (2)
cms-web_1 | New install
cms-web_1 | Provisioning Database
cms-web_1 | ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/run/mysqld/mysqld.sock’ (2)
cms-web_1 | Phinx by CakePHP - https://phinx.org. 0.9.2
cms-web_1 |
cms-web_1 | using config file .varwwwcmsphinx.php
cms-web_1 | using config parser php
cms-web_1 | using migration paths
cms-web_1 | - /var/www/cms/db/migrations
cms-web_1 | warning no environment specified, defaulting to: production
cms-web_1 | using adapter mysql
cms-web_1 | using database headoffice
cms-web_1 |
cms-web_1 |
cms-web_1 | [InvalidArgumentException]
cms-web_1 | There was a problem connecting to the database: SQLSTATE[HY000] [2002] No s
cms-web_1 | uch file or directory
cms-web_1 |
cms-web_1 |
cms-web_1 | migrate [-c|–configuration CONFIGURATION] [-p|–parser PARSER] [-e|–environment ENVIRONMENT] [-t|–target TARGET] [-d|–date DATE] [-x|–dry-run]
cms-web_1 |
cms-web_1 | Configuring Database Settings
cms-web_1 | ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/run/mysqld/mysqld.sock’ (2)
cms-web_1 | ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/run/mysqld/mysqld.sock’ (2)
cms-web_1 | ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/run/mysqld/mysqld.sock’ (2)
cms-web_1 | ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/run/mysqld/mysqld.sock’ (2)
cms-web_1 | ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/run/mysqld/mysqld.sock’ (2)
cms-web_1 | ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/run/mysqld/mysqld.sock’ (2)
cms-web_1 | Setting up Maintenance
cms-web_1 | Protected Maintenance
cms-web_1 | ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/run/mysqld/mysqld.sock’ (2)
cms-web_1 | ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/run/mysqld/mysqld.sock’ (2)
cms-web_1 | Importing ca-certs
cms-web_1 | cp: can’t stat ‘/var/www/cms/ca-certs/.pem’: No such file or directory
cms-web_1 | cp: can’t stat '/var/www/cms/ca-certs/
.crt’: No such file or directory
cms-web_1 | WARNING: ca-certificates.crt does not contain exactly one certificate or CRL: skipping
cms-web_1 | Configuring Maintenance

You need to specify the IP address of the MySQL server in config.env.

127.0.0.1 won’t be it as that’s the loopback interface of the container, and also MySQL considers that to be a special case meaning “local socket”.

It will need to be the LAN IP address of the server running your mysql proxy.

1 Like