mysql root 权限丢了_mysql root权限丢失只能看到information_schema数据库

mysql root权限丢失只能看到information_schema数据库解决办法

用服务器权限SSH登录Flashfxp,下载/etc/my.conf 用Editplus打开

[mysqld]

port        = 3306

socket        = /tmp/mysql.sock

skip-external-locking

key_buffer_size = 128M

max_allowed_packet = 1M

table_open_cache = 256

sort_buffer_size = 1M

read_buffer_size = 1M

read_rnd_buffer_size = 2M

myisam_sort_buffer_size = 8M

thread_cache_size = 8

query_cache_size= 16M

thread_concurrency = 8

max_connections = 300

wait_timeout = 30

interactive_timeout = 30

max_connect_errors = 9

long_query_time = 1

tmp_table_size = 16M

#log-bin=mysql-bin

#binlog_format=mixed

#server-id    = 1

skip-grant-tables

在my.conf的[mysqld]字段内尾部加入skip-grant-tables,保存,并覆盖服务器/etc/my.conf

pytty 客户端ssh登录客户端,root权限登录,运行 service mysqld restart 重启mysql

执行:mysql -u root -p

Enter password: (直接回车)

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 1

Server version: 5.1.61 Source distribution

Copyright (c) 2000, 2011,Oracleand/or its affiliates. All rights reserved.

oracleis a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective

owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

执行:use mysql

Database changed

执行:flush privileges;

执行:grant all privileges on *.* to root@localhost identified by 'mysql'

OK完成了,等等,登录进去没权限?往下看!

root用户已添加完成。接下来是授权:

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';

好了,完成!再等等!登录进去root账户没有新建数据库权限?往下看!

下载/etc/my.conf 用editplus 打开去掉 skip-grant-tables

重启mysql: service mysqld restart

OK这次是真的好了!!!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值