忘记root密码的更改方式及常见错误,附图:user表的正确格式

来源:互联网 发布:网络动漫黑名单 编辑:程序博客网 时间:2024/05/20 06:28

part 1   在mysql root密码忘记的情况下。

可以使用 /usr/bin/mysqld_safe --skip-grant-tables 运行mysql应用。然后给root重置密码。

update MySQL.user set password=PASSWORD('新密码') where User='root';

Part2 重置密码后,需要给root用户赋权:


GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'root' WITH GRANT OPTION; 


FLUSH PRIVILEGES;

这样之后,获得的数据库中  use mysql; select * from user; 会得到如下的图:




Part 3  常见的问题

1  ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO) ---> 密码不对 或 权限不足,前者可能性大

2  ERROR 1820 (HY000): You must SET PASSWORD before executing this statement --->SET PASSWORD = PASSWORD('123456');这句话重新运行一次

3  ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement ---> 取消 带参运行。
4$nbsp; ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (111) ---> mysql 进程没有运行!


原创粉丝点击