Docker-compose mysql environment difference between PASSWORD and ROOT_PASSWORD
From the documentation(https://hub.docker.com/_/mysql/)...
MYSQL_USER, MYSQL_PASSWORD
These variables are optional, used in conjunction to create a new user and to set that user's password. This user will be granted superuser permissions (see above) for the database specified by the MYSQL_DATABASE variable. Both variables are required for a user to be created.
So this is to create a new user with a password. MYSQL_ROOT_PASSWORD is the password for the root user of MySQL.
MYSQL_ROOT_PASSWORD This variable is mandatory and specifies the password that will be set for the MySQL root superuser account. In the above example, it was set to my-secret-pw.
helloworld123
Updated on June 28, 2022Comments
-
helloworld123 almost 2 years
This is from my docker compose:
db: image: mysql ports: - "3306:3306" environment: MYSQL_DATABASE: myDb MYSQL_USER: user MYSQL_PASSWORD: test MYSQL_ROOT_PASSWORD: test volumes: - ./dump:/docker-entrypoint-initdb.d - persistent:/var/lib/mysql
When I change my user and both passwords to 'root', my database gets created but it's empty. When I leave the credentials as above, my .sql script inside my /dump dir populates the database as it is supposed to. How do the credentials change affect data injection and how can I fix this?
-
helloworld123 about 6 yearsI havent looked into it too much, but I believe that a username and password cannot be the same. And they both cannot be equal to the root password.