標籤:identified
mysql許可權的誤操作的恢複
原因:由於誤操作,我把repl使用者授予了所有許可權,但刪除了資料庫中的其他使用者及許可權,因此repl使用者雖然具有操作所有資料庫的許可權,但沒有grant許可權,所以若想授予其他使用者權限,來管理資料庫,出現這種狀況就酷斃了,沒有授予許可權怎麽辦?
誤操作過程:
mysql >grant all on *.* to ‘repl‘@‘192.168.1.%‘ identified by ‘123456‘;
mysql> flush privileges;
授予完以後,我把其他的所有使用者全部都刪除了,再來查看此時的使用者
mysql> select host,user,password from mysql.user;
+--------------+------+-------------------------------------------+
| host | user | password |
+--------------+------+-------------------------------------------+
| 192.168.1.% | repl | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |
+--------------+------+-------------------------------------------+
查看授予使用者的許可權會發現grant許可權為N
mysql> select * from mysql.user\G;
*************************** 2. row ***************************
Host: 192.168.1.%
User: repl
Password: *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9
Select_priv: Y
Insert_priv: Y
Update_priv: Y
Delete_priv: Y
Create_priv: Y
Drop_priv: Y
Reload_priv: Y
Shutdown_priv: Y
Process_priv: Y
File_priv: Y
Grant_priv: N
References_priv: Y
Index_priv: Y
Alter_priv: Y
Show_db_priv: Y
Super_priv: Y
Create_tmp_table_priv: Y
Lock_tables_priv: Y
Execute_priv: Y
Repl_slave_priv: Y
Repl_client_priv: Y
Create_view_priv: Y
Show_view_priv: Y
Create_routine_priv: Y
Alter_routine_priv: Y
Create_user_priv: Y
Event_priv: Y
Trigger_priv: Y
Create_tablespace_priv: Y
ssl_type:
ssl_cipher:
x509_issuer:
x509_subject:
max_questions: 0
max_updates: 0
max_connections: 0
max_user_connections: 0
plugin: mysql_native_password
authentication_string:
password_expired: N
我的做法:
mysql> update mysql.user set Grant_priv=‘Y‘ where user=‘repl‘ and host=‘192.168.1.%‘;
mysql>\q
再次登入
mysql >flush privileges;
你會發現令人高興的現象,授予其它使用者權限竟然OK了
mysql> grant all on *.* to ‘test1‘@‘192.168.1.%‘ identified by ‘123456‘;
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
本文出自 “7240173” 部落格,請務必保留此出處http://wwdyl.blog.51cto.com/7240173/1640430
mysql許可權的誤操作的恢複