ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement
时间: 2023-09-13 13:05:13 浏览: 125
这个错误是因为 MySQL 服务器当前处于跳过权限验证模式,无法执行修改用户密码这样需要权限验证的操作。
你需要先退出跳过权限验证模式,然后再执行修改密码的操作。可以按照以下步骤操作:
1. 以管理员身份重启 MySQL 服务器,不要使用 `--skip-grant-tables` 参数。
2. 登录 MySQL 服务器,使用 `mysql -u root -p` 命令以 root 用户身份登录。
3. 执行以下 SQL 语句来更新 root 用户的密码:
```
ALTER USER 'root'@'localhost' IDENTIFIED WITH caching_sha2_password BY 'your_new_password';
```
其中,`your_new_password` 是你想要设置的新密码,需要替换为实际的密码。
执行完毕后,你可以再次启用跳过权限验证模式,但为了安全起见,不建议长期开启跳过权限验证模式。
相关问题
error 1290 (hy000): the mysql server is running with the --skip-grant-tables option so it cannot execute this statement
这个错误消息表明 MySQL 服务器正在使用 "--skip-grant-tables" 选项运行,因此无法执行此语句。在这种模式下,MySQL 不会检查用户账号和权限,所有用户都可以访问数据库,这可能会导致数据安全问题,建议您确认是否正确使用该选项并在正式环境下禁用该选项。
改密码时ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement
### 解决 MySQL 修改密码时遇到 `ERROR 1290 (HY000)` 的方案
当尝试修改 MySQL 用户密码并收到错误消息 `ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement`[^1],这意味着当前 MySQL 实例是以跳过权限表的方式启动的。这通常发生在忘记 root 密码的情况下,为了能够绕过认证机制而采取的一种临时措施。
要解决这个问题,需要先停止带有 `--skip-grant-tables` 参数运行的服务实例:
```bash
sudo systemctl stop mysql
```
接着正常启动 MySQL 而不带任何特殊参数:
```bash
sudo systemctl start mysql
```
此时应该能正常使用命令行工具连接到数据库,并执行更改用户凭证的操作。对于 MySQL 8.0 及以上版本来说,更新用户的验证信息应当采用如下 SQL 命令格式:
```sql
ALTER USER 'root'@'localhost' IDENTIFIED BY 'new_password';
FLUSH PRIVILEGES;
```
上述语句会改变指定账户的身份识别方式及其关联的新密码;随后刷新权限缓存使得改动立即生效[^3]。
完成这些步骤后记得保存好新的管理员账号密钥组合以便日后维护工作之需。另外,在处理完毕之后务必确认 MySQL 配置文件中不存在 `skip-grant-tables` 设置项以免再次触发相同问题。
阅读全文
相关推荐












