標籤:mysql root許可權最佳化後沒有grant許可權
原先資料庫裡root使用者授權登入主機為%
mysql> show grants for [email protected]"%"; +--------------------------------------------------------------------------------------------------------------------------------+| Grants for [email protected]% |+--------------------------------------------------------------------------------------------------------------------------------+| GRANT ALL PRIVILEGES ON *.* TO ‘root‘@‘%‘ IDENTIFIED BY PASSWORD ‘*ABE28A948664E6CEA78541ABEE3A910833361F23‘ WITH GRANT OPTION |+--------------------------------------------------------------------------------------------------------------------------------+1 row in set (0.00 sec)mysql>
重新添加主機[email protected]和[email protected] 然後刪除[email protected]"%", flush privileges。整好之後以為完事了。然後再添加授權的時候糗事發生了。
mysql> grant all on *.* to [email protected]"111.74.99.66" ;ERROR 1045 (28000): Access denied for user ‘root‘@‘localhost‘ (using password: YES)
我給root授權的時候明明給的all呀,咋就沒授權許可權呢?
一番百度之後並和其他資料庫的root使用者對比,最終查詢user表的root使用者的Grant_priv欄位發現為N。
15:05:18 15:05:28 mysql> select user,host,Grant_priv from user; 15:05:28 +---------+---------------+------------+15:05:28 | user | host | Grant_priv |15:05:28 | root | 127.0.0.1 | N |15:05:28 | root | localhost | N |15:05:28 +---------+---------------+------------+15:05:28 10 rows in set (0.00 sec)15:05:28 15:07:33 mysql>
心驚膽顫的將root使用者的Grant_priv 欄位修改為Y,
15:17:10 mysql> update mysql.user set Grant_priv="Y" where user="root" and host="localhost";15:17:10 Query OK, 1 row affected (0.00 sec)15:17:19 mysql> flush privileges;15:17:19 Query OK, 0 rows affected (0.00 sec)15:17:20 mysql> Bye
然後退出登入,再進來授權,問題解決。
15:18:05 mysql> grant all on mysql.* to ‘root‘@‘111.74.99.66‘;15:18:05 Query OK, 0 rows affected (0.00 sec)
授權all許可權後,啥許可權都有就是沒有grant許可權。
本文出自 “大麥茶” 部落格,請務必保留此出處http://damaicha.blog.51cto.com/6046098/1870607
mysql root許可權最佳化後沒有grant許可權