修改 MySQL 登录密码
mysql5.7忘记root密码
- 直接使用 /etc/mysql/debian.cnf 文件中 [client] 节提供的用户名和密码
mysql -u*** -p
- 切换到 mysql 数据库
use mysql;
- 更新密码
update user set authentication_string = password('root'), password_expired = 'N', password_last_changed = now() where user = 'root';
- 刷新权限 flush privileges;
- 重启 mysqld 服务,再用新密码登录即可
- 如果无法登录,提示 Access denied for user 'root'@'localhost'
- 重新更新 root 用户的 plugin 字段
- update user set plugin='mysql_native_password' where user = 'root';
- 更新成功后.重新执行更新密码操作
重启mysql服务
本作品采用《CC 协议》,转载必须注明作者和本文链接
推荐文章: