日期:2014-05-16  浏览次数:20707 次

mysql用户列表是空的,root登录不了。怎么办?
登录mysql时总是提示:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
后来进入用 /usr/local/mysql/bin/mysqld_safe --skip-grant-tables --user=root进入修改了密码,提示成功,但是还是进不了,提示一样的错误。
有一点很奇怪,我用--skip-grant-tables进去查看了一下用户列表是空的。
mysql> select user from mysql.user;
Empty set (0.00 sec)
怎么解决啊?

------解决方案--------------------
mysqld -skip-grant-tables
/etc/init.d/mysql start –mysqld –skip-grant-tables


------解决方案--------------------
1、使用—skip-grant-tables选项来启动MySQL服务

>mysqld –skip-grant-tables

 

#/etc/init.d/mysql start –mysqld –skip-grant-tables

 

2、登录root,设置新密码

mysql –u root

update mysql.user set password=password(“new_password”) where user=’root’and host=’localhost’;

 

3、加载权限表

fush privileges;


------解决方案--------------------
进入以后,加用户
grant all on *.* to root@'localhost' identified by 'yourpassword';
grant all on *.* to root@'%' identified by 'yourpassword';



------解决方案--------------------
1、使用—skip-grant-tables选项来启动MySQL服务

>mysqld –skip-grant-tables

2.创建root并赋予权限
grant all on *.* to root@'localhost' identified by 'password';
grant all on *.* to root@'%' identified by 'password';