Is multiple default MySQL servers feasible in Docker's phpMyAdmin?
P粉718730956
2023-08-25 21:56:14
<p>I'm trying to use Docker to build an environment that includes two MySQL servers and a phpMyAdmin server to easily analyze data during development.
My docker-compose.yml file is as follows. </p>
<pre class="brush:php;toolbar:false;">version: "3.9"
services:
database1:
container_name: Database1
image: mysql:8.0.28
command: --default-authentication-plugin=mysql_native_password
restart: always
environment:
MYSQL_DATABASE: database1
MYSQL_ROOT_PASSWORD: somepassword
MYSQL_USER: databaseuser1
MYSQL_PASSWORD: databaseuser1
ports:
- "3306:3306"
volumes:
- database-volume:/var/lib/mysql
networks:
-my_network
database2:
container_name: Database2
image: mysql:8.0.28
command: --default-authentication-plugin=mysql_native_password
restart: always
environment:
MYSQL_DATABASE: database2
MYSQL_ROOT_PASSWORD: somepassword
MYSQL_USER: databaseuser2
MYSQL_PASSWORD: databaseuser2
ports:
- "3307:3306"
volumes:
- second-database-volume:/var/lib/mysql
networks:
-my_network
phpmyadmin:
container_name: PhpMyAdmin
image: phpmyadmin/phpmyadmin:5.1.3
restart: always
depends_on:
- database1
- database2
environment:
PMA_HOST: database1, database2
PMA_PORT: 3306, 3307
PMA_USER: databaseuser1, databaseuser2
PMA_PASSWORD: databaseuser1, databaseuser2
ports:
- "8080:80"
networks:
-my_network
volumes:
database-volume:
second-database-volume:
networks:
my_network:
driver: bridge</pre>
<p>I would like to know if there is a built-in way to achieve this. </p>
Have you tried changing the environment variable
PMA_HOST
toPMA_HOSTS
?Official phpMyAdmin Docker Image