Reputation: 3102
In docker compose file i have phpmyadmin, like this
phpmyadmin:
image: phpmyadmin/phpmyadmin
hostname: 'phpmyadmin'
container_name: 'phpmyadmin'
links:
- database:db
environment:
MYSQL_USER: root
MYSQL_PASSWORD: secret
MYSQL_ROOT_PASSWORD: secret
ports:
- 8000:80
When i use this password and user to try login in phpmyadmin, returns that no authorized. So, how can i change default user and password for phpmyadmin docker?
Upvotes: 3
Views: 10101
Reputation: 173
From https://hub.docker.com/r/phpmyadmin/phpmyadmin/
phpMyAdmin connects using your MySQL server credentials. Please check your corresponding database server image for information on the default username and password or how to specify your own custom credentials during installation.
The MySQL server credentials can be defined in MySQL docker container by using the MYSQL_* environment variables. Here is a docker-compose example from the dockerhub website:
version: '3.1'
services:
db:
image: mariadb:10.3
restart: always
environment:
MYSQL_ROOT_PASSWORD: notSecureChangeMe
phpmyadmin:
image: phpmyadmin
restart: always
ports:
- 8080:80
environment:
PMA_ARBITRARY: 1
Here you can login in phpmyadmin as root with the password "notSecureChangeMe" (Server: db).
If you want to login in phpmyadmin directly without providing user and password then you need to use config authentication mode (https://docs.phpmyadmin.net/en/release_5_0_4/setup.html#config-authentication-mode) and provide the credentials in phpmyadmin config file.
This is very easy to configure in docker-compose file (by using PMA_* environment variables):
version: '3.1'
services:
db:
image: mariadb:10.3
restart: always
environment:
MYSQL_ROOT_PASSWORD: notSecureChangeMe
phpmyadmin:
image: phpmyadmin
restart: always
ports:
- 8080:80
environment:
PMA_HOST: 'db'
PMA_USER: 'root'
PMA_PASSWORD: 'notSecureChangeMe'
Upvotes: 6