我喜欢SEO、网络营销及建站,希望与志同道合的您
建立合作或相互学习关系 QQ:10343829

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, Oracle and/or its affiliates. All rights reserved.

oracle is 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这次是真的好了!!!

转载请著名来源:天天小站 » mysql root权限丢失只能看到information_schema数据库

分享到:更多 ()