如果你在部署 MySQL 8.0 时忘记了密码,可以按照以下步骤修改密码:

  1. 停止 MySQL 服务:

    sudo systemctl stop mysql
    
  2. 以跳过权限验证的方式启动 MySQL 服务:

    sudo mysqld_safe --skip-grant-tables &
    
  3. 连接到 MySQL 服务器:

    mysql -u root
    
  4. 在 MySQL 提示符下,切换到 mysql 数据库:

    use mysql;
    
  5. 更新 root 用户的密码:

    update user set authentication_string=password('new_password') where user='root';
    

    注意将 new_password 替换为你想要设置的新密码。

  6. 刷新权限:

    flush privileges;
    
  7. 退出 MySQL 提示符:

    quit;
    
  8. 停止 MySQL 服务:

    sudo systemctl stop mysql
    
  9. 启动 MySQL 服务:

    sudo systemctl start mysql
    

现在你应该可以使用新密码登录 MySQL 了

docker部署mysql80忘记密码了怎么修改

原文地址: http://www.cveoy.top/t/topic/iVnk 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录