Home > database >  Two MySQL docker container
Two MySQL docker container

Time:06-15

I have a server that already run a MySQL server container on port 3306:3306 (build from a docker-compose.yml file)

I would like to run another MySQL container on port 3307:3306 from another docker-compose.yml. The problem is that for the second container the MYSQL_ROOT_PASSWORD is never set and I got an access denied.

Both containers are targeting different volumes.

Is it possible to run two MySQL container from two different docker-compose.yml file on the same server?

CodePudding user response:

You are able to run 2 instances of MySQL on the same host and they don't interfere with each other.

What I think is causing your issue is that the environment variable MYSQL_ROOT_PASSWORD (and other environment variables) is only used when the container is started witout an existing database. If a database already exists, then the root password stored in the database is used.

You need to find out what root password was set when the database was created and use that.

CodePudding user response:

The problem it's solved.

docker-compose.yml doesn't accept env variable with the char $. To solve it we must escape the char like this : $$.

Thank's for you'r help guys.

  • Related