MySQL-重置root密码问题

当忘记root管理员账号密码问题

适用于忘记root密码的情况及异机恢复时没有管理员账号密码的情形

# 跳过权限验证启动服务
/usr/local/mysql/bin/mysqld_safe --defaults-file=/etc/my.cnf  --skip-grant-tables 


# 2. 登录mysql
/usr/local/mysql/bin/mysql

# 3. 可能遇到不能修改的情况,如下:
mysql> ALTER USER ‘root‘@‘localhost‘ IDENTIFIED WITH mysql_native_password BY ‘root‘;
ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement

# 4. 执行`flush privileges;`后再次执行修改密码的命令即可
mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)

mysql> ALTER USER ‘root‘@‘localhost‘ IDENTIFIED WITH mysql_native_password BY ‘root‘;
Query OK, 0 rows affected (0.00 sec)

mysql> flush privileges;

# 5. 打开新窗口验证修改的账号密码是否可以登录

# 6. 问题解决

MySQL-重置root密码问题

上一篇:oracle监听报The listener supports no services


下一篇:Entity Framework(EF) 之database first