Comments - How to change root to native-password plugin with dockerhub image

2 years, 9 months ago James Stewart Miller
This comment has the status of 'removed' and can only be seen by you.

I see you are using version 10.5. I have been trying with the mariadb:latest image, which I now see defaults to version 10.5.

When I try the following commands in a script:

read -p "Enter your MYSQL_ROOT_PASSWORD : " mysql_root_password podman exec -e MYSQL_ROOT_PASSWORD=${mysql_root_password} -e DB_NAME=${DB_NAME} -e DB_USER=${DB_USER} -e DB_HOST=${DB_HOST} -e DB_PASSWORD=${DB_PASSWORD} -it ${MARIA_CONT_NAME} bash -c "mysql -uroot -p\${MYSQL_ROOT_PASSWORD} -hlocalhost -e \"CREATE DATABASE \${DB_NAME} CHARSET utf8; grant all privileges on \${DB_NAME}.* TO \${DB_USER}@\${DB_HOST} identified by '$\{DB_PASSWORD}';\""

or when I try and log in from a command line having exec'ed into a bash session inside the maria container, I get the following error: ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

I have checked and the variable 'mysql_root_password' does not contain a newline character. There is no space between -p and the password in any command.

This is my command for making the Mariadb secret: $(read -p "Enter variable for MARIADB_ROOT_PASSWORD : " token) && printf token | podman secret create "MARIADB_ROOT_PASSWORD" -

which I then later use: podman run -dit --secret=MARIADB_ROOT_PASSWORD,type=env --name ${MARIA_CONT_NAME} --pod ${POD_NAME} ${MARIA_IMAGE}

the above run command is followed immediately by:

read -p "Enter your MYSQL_ROOT_PASSWORD : " mysql_root_password

podman exec -e MARIADB_ROOT_PASSWORD=${mysql_root_password} -e DB_NAME=${DB_NAME} -e DB_USER=${DB_USER} -e DB_HOST=${DB_HOST} -e DB_PASSWORD=${DB_PASSWORD} -it ${MARIA_CONT_NAME} bash -c "mysql -uroot -p\${MARIADB_ROOT_PASSWORD} -hlocalhost -e \"CREATE DATABASE \${DB_NAME} CHARSET utf8; grant all privileges on \${DB_NAME}.* TO \${DB_USER}@\${DB_HOST} identified by '$\{DB_PASSWORD}';\""

And this command (or me manually trying to log into the mariadb with the root password) fails with access denied.

I am creating it this way, because I want to use the command 'podman generate systemd --files --new' so that the systemd script create the container from new each time. So, I will, if I can connect to mariadb, mount the /var/lib/sql directory on the host in the run command. The aim is that the newly created by systemd container will reuse the database each time.

But I can't get this basic command to work. I have tried creating the maria container with -e MARIADB_ROOT_PASSWORD="some_password", but I still get no luck.

I'm stumped...

 
Content reproduced on this site is the property of its respective owners, and this content is not reviewed in advance by MariaDB. The views, information and opinions expressed by this content do not necessarily represent those of MariaDB or any other party.