忘记MySQL/MariaDB root密码的解决方法
MySQL/MariaDB 的root 密码忘了,不知道改怎么办,下面是修改root 密码步骤。
Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '/h' for help. Type '/c' to clear the current input statement.
MariaDB [(none)]> set password = password('123');
ERROR 1290 (HY000): The MariaDB server is running with the --skip-grant-tables option so it cannot execute this statement
MariaDB [(none)]> use mysql
Database changed
MariaDB [mysql]> update user set password=password('root') where user='root' and host='localhost';
Query OK, 0 rows affected (0.00 sec)
Rows matched: 1 Changed: 0 Warnings: 0
此时,由于使用了--skip-grant-tables 选项启动,使用“set password”命令更改密码失败,直
接更新user 表的password 字段后更改密码成功。
(4)刷新权限表,使得权限认证重新生效:
MariaDB [mysql]> flush privileges;
Query OK, 0 rows affected (0.00 sec)
Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '/h' for help. Type '/c' to clear the current input statement.
至此密码修改成功