备忘录:解决无法使用”update mysql.user set password=PASSWORD(”)”命令的方法

摘要

我忘记了MariaDB的root密码。
执行【update mysql.user set password=PASSWORD(”)】时出现了错误。

解决方案

使用这个应该可以
【alter user ‘root’@’localhost’ identified BY ”】
在BY后面的”之间输入新设置的密码。

详细的步骤

1. 停止MariaDB
mac: 【mysql.server stop】

2. 启动安全模式
mac 【mysql.server start –skip-grant-tables】

3. 连接MariaDB

4. 执行【use mysql;】

5. 执行【alter user ‘root’@’localhost’ identified BY ”】

6. 重新启动MariaDB