蓝色动力网络

找网吧系统
就到网吧系统下载站

解决误删Mysql中Root所有权限的方法!

作者:admin人气:0来源:网吧系统下载站2015-08-03 09:32:52

广告载入中...

长时间的对着电脑,造成了"神志不清",一不小心在Mysql下误操作了“revoke all on *.* from 'root'@'localhost'; ”,这个命令的意思就是删除mysql中最高权限的用户root的所有权限。因为本机mysql的密码为空,虽然依旧可以进去mysql,但再也不法执行修改操作。

解决方法:

1、首先杀掉mysql进程

#pkill mysql

2、以--skip-grant-tables方式启动

#/usr/local/mysql/bin/mysqld_safe  --user mysql --skip-grant-tables&

3、更新的MYSQL.USER表的所有字段中为N的为Y

# /usr/local/mysql/bin/mysql  进入mysql

>use mysql;

update user set Select_priv ='Y' where user = 'root';

update user set Insert_priv ='Y' where user = 'root';

update user set Update_priv ='Y' where user = 'root';

update user set Delete_priv ='Y' where user = 'root';

update user set Create_priv ='Y' where user = 'root';

update user set Drop_priv ='Y' where user = 'root';

update user set Reload_priv ='Y' where user = 'root';

update user set Shutdown_priv ='Y' where user = 'root';

update user set Process_priv ='Y' where user = 'root';

update user set File_priv ='Y' where user = 'root';

update user set Grant_priv ='Y' where user = 'root';

update user set References_priv ='Y' where user = 'root';

update user set Index_priv ='Y' where user = 'root';

update user set Alter_priv ='Y' where user = 'root';

update user set Show_db_priv ='Y' where user = 'root';

update user set Super_priv ='Y' where user = 'root';

update user set Create_tmp_table_priv ='Y' where user = 'root';

update user set Lock_tables_priv ='Y' where user = 'root';

update user set Execute_priv ='Y' where user = 'root';

update user set Repl_slave_priv ='Y' where user = 'root';

update user set Repl_client_priv ='Y' where user = 'root';

update user set Create_view_priv ='Y' where user = 'root';

update user set Show_view_priv ='Y' where user = 'root';

update user set Create_routine_priv ='Y' where user = 'root';

update user set Alter_routine_priv ='Y' where user = 'root';

update user set Create_user_priv ='Y' where user = 'root';

update user set Event_priv ='Y' where user = 'root';

update user set Trigger_priv ='Y' where user = 'root';


总结:

权限问题最后要保证“mysql.user”表中 host为“localhost”和“%”都有root的所有权限。

host列是指定登录的ip,比如说 user=root host=192.168.1.1 ,这里的意思就是说,root用户只能通过 192.168.1.1的客户端去访问,而%则是个通配符, 如果host=192.168.1.%,那么就表示 只要是 ip为host=192.168.1.前缀的客户端都可以连接,那么host=%的话则表示所有ip都有权去连接,这也就是为什么在开启远程连接的时候,大部分人都直接把host改成%的缘故,因为省事。

继续阅读:Mysql

分享吧~提高逼格:

栏目分类

热门下载

More
官方微信二维码蓝色动力官方微信公众号