美文网首页Docker容器
docker | mysql重置root密码

docker | mysql重置root密码

作者: 炒面Z | 来源:发表于2020-04-01 14:56 被阅读0次

忘记密码怎么办

  • 修改mysql的配置文件my.cnf,重启mysql容器
[mysqld]
#免密码登录
skip-grant-tables
  • 免密码登录进console界面,执行修改账号密码sql语句即可
改密码的语句:
update mysql.user set authentication_string='123456' where user='root';
root@shu:/opt/mysql# docker exec -it mysql  bash
root@a7360c453c6b:/# mysql -uroot -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 11
Server version: 5.7.28 MySQL Community Server (GPL)

Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> update mysql.user set authentication_string='123456' where user='root';
image.png
  • 最后记得把 mysql的配置文件my.cnf 改回来
[mysqld]
# 免密码登录 - 重置密码完毕要删除or注释
# skip-grant-tables

相关文章

网友评论

    本文标题:docker | mysql重置root密码

    本文链接:https://www.haomeiwen.com/subject/anqauhtx.html