标签: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
标签:identified
原文地址:http://wwdyl.blog.51cto.com/7240173/1640430