Docker构成了PASSWORD和ROOT_PASSWORD之间的mysql环境差异

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?

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.