How could I change root password in docker container since the container stop automatically once I stop the mysql service.
Should I stop the mysql container and deploy
In case you forgot the old password, you can reset it following a few steps. I wrote a tutorial on how to do it (you can show you support by giving a few claps): https://medium.com/@marinbinzari/reset-root-mysql-password-in-docker-d961c71285e4
TLDR: create a mysql-init.sql
file with the queries to reset the password:
USE mysql;
UPDATE user SET Password=PASSWORD('YOURNEWPASSWORD') WHERE User='root';
FLUSH PRIVILEGES;
Mount the file in the /tmp
folder, run the container (not execute so MySQLD is not started) and then start the mysqld with the init script.
mysqld_safe --init-file=/tmp/mysql-init.sql &
Try to connect, exit the docker container and start using the new password