[英]Reset password mysql in docker container
I am running MySql on a docker container.我在 docker 容器上运行 MySql。 I use it for my WordPress databases.
我将它用于我的 WordPress 数据库。 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.
它一直工作正常,但我想检查一些事情,因为我从 WordFence 收到警告,说一个用户是在 Wordpress 之外创建的。
However, I don't seem to recall what the root password was.但是,我似乎不记得 root 密码是什么。 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.
按照本指南( https://www.techrepublic.com/article/how-to-set-change-and-recover-a-mysql-root-password/ )我尝试重置密码,但总是出现错误说 mysqld_safe 已经在另一个进程上运行。
When I do a ps -x
, I get this:当我执行
ps -x
,我得到了这个:
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.我不知道如何使用 -skip-grant-tables 运行
mysqld_safe
。 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.我发现更奇怪的是,当我执行
service mysql stop
,它说它停止了 mysql,但我仍然可以访问博客 - 只有停止容器才能将其关闭。
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.然后,当在 bash 中时,我可以简单地运行
mysqld_safe --skip-grant-tables &
并像经常在网上解释的那样更改 root 密码。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.