I am running MySql on a docker container. I use it for my WordPress databases. It has been working fine, but I wanted to check some things as I got a warning from WordFence that a user was created outside Wordpress.
However, I don't seem to recall what the root password was. Following this guide (https://www.techrepublic.com/article/how-to-set-change-and-recover-a-mysql-root-password/) I tried to reset the password, but I always get an error saying that mysqld_safe is already running on another process.
When I do a ps -x
, I get this:
PID TTY STAT TIME COMMAND
1 ? Ss 0:00 /bin/sh /usr/bin/mysqld_safe
92 pts/0 Ss 0:00 bash
115 pts/0 R+ 0:00 ps -x
I can't seem to kill this process. I have no idea how to run mysqld_safe
with -skip-grant-tables.
What I find even more weird is that when I do a service mysql stop
, it says it stops mysql, but I can still access the blog - only stopping the container brings it down.
Any clue on what I could do here?
I found how to do it.
I have to stop the container:
docker stop my-container
Then, I need to commit my container to a new image:
docker commit my-container temp-container
I mount this one temporarily:
docker run -it --name some_name -d --entrypoint=bash -v the-volume:/var/lib/mysql temp_container
docker attach some_name
Then, when inside the bash, I can simply run mysqld_safe --skip-grant-tables &
and change the root password like often explained on the web.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With