[英]Reset 'root' user password in MySQL 5.7.x+
当我尝试使用以下命令在ubuntu系统上重置MySQL根密码时
update user set password=PASSWORD("newPwd") where User="root";
我认为错误是
ERROR 1054 (42S22): Unknown column 'password' in 'field list'
在MySQL 5.7中,删除了mysql.user表字段中的password字段,现在该字段名称为'authentication_string'。
请按照以下步骤在Ubuntu上重置“ root”密码
停止服务
sudo /etc/init.d/mysql stop
在没有密码的情况下启动MySQL
sudo mysqld_safe --skip-grant-tables &
**Note: the following command didn't work for me**
mysqld --skip-grant-tables &
连接到MySQL
mysql -uroot
设置新的MySQL根密码
mysql> use mysql;
mysql> update user set authentication_string=password('yourNewPwd') where user='root';
mysql> flush privileges;
mysql> quit
重新启动mysql服务
sudo /etc/init.d/mysql stop
sudo /etc/init.d/mysql start
现在,您可以使用更新的密码登录
mysql -u root -p
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.