由于mysql5.7密码字段已取消password字段,改成了新的"authentication_string".因此修改密码的命令需要变更如下:
首先登录mysql,切换到mysql库,然后执行修改命令,最后要刷新下权限.
MySQL [mysql]> use mysql;
MySQL [mysql]> update user set authentication_string=password('m@4hCw9UN97WiV&x') where user='root';
Query OK, 2 rows affected, 1 warning (0.01 sec)
Rows matched: 2 Changed: 2 Warnings: 1
MySQL [mysql]> flush privileges;
Query OK, 0 rows affected (0.00 sec)
以下是mysql5.6版本的修改密码方式:
mysql> use mysql;
mysql> UPDATE user SET Password = PASSWORD('新密码') WHERE user = 'root';
mysql> FLUSH PRIVILEGES;
如果忘记root密码,可以用这种方式:
mysqld_safe --skip-grant-tables&
mysql -u root mysql
mysql> UPDATE user SET password=PASSWORD("新密码") WHERE user='root';
mysql> FLUSH PRIVILEGES;
本文由 Mr Gu 创作,采用 知识共享署名4.0 国际许可协议进行许可
本站文章除注明转载/出处外,均为本站原创或翻译,转载前请务必署名
最后编辑时间为: May 12, 2024 at 04:53 pm