打开终端输入:
sudo mysqld_safe --skip-grant-tables
输出 password: logging to '/usr/local/mysql/data/localhost.err'. 2018-10-10t03:21:40.6nz mysqld_safe starting mysqld daemon with databases from /usr/local/mysql/data
打开一个新的终端,输入 mysql -u root
welcome to the mysql monitor. commands end with ; or g. your mysql connection id is 16 server version: 5.7.23 mysql community server (gpl) copyright (c) 2000, 2018, 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>
终端输入 use mysql 显示如下
database changed
修改密码
alter user 'root'@'localhost' identified by '12345678';
发现报错 error 1290 (hy000): the mysql server is running with the --skip-grant-tables option so it cannot execute this statement
解决:
先执行
flush privileges;
再次修改密码
alter user 'root'@'localhost' identified by '12345678';
query ok, 0 rows affected (0.13 sec) // 修改成功
【说明】:本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:254677821)!