'root' has exceeded the 'max_questions' resource (current value: 100) (1226),qtresourceroot
同事遇到一問題
mysqldump: Couldn't execute 'select @@collation_database': User 'root' has exceeded the 'max_questions' resource (current value: 100) (1226)
按照提示很容易想到 max_questions 值太大了,目前只有100,所以報錯。
首先想到show variables like 'r' 居然沒有找到,這個應該不是個全域的參數,那麼在哪兒呢?應該在系統資料表裡。
然後進去的資料庫裡面,想看下多少串連,show full processlist,報一樣的錯誤,任何的select 語句都是報這個錯誤。
幸好只是個開發測試庫,所以直接重啟DB應該可以解決此問題。果不其然,重啟之後一切ok。
進入到mysql庫,查看user表,發現如下欄位
max_questions | int(11) unsigned | NO | | 0 |
此庫設定的值確實為100,改為0,重新整理許可權。
一般情況下,使用者是不會修改這個值,0的話就是沒有限制,不知道誰手欠,修改了這個值。
按照這樣,應該是針對單個使用者的限制。
解決此問題,應該用別的超級許可權的使用者登入,直接修改這個值,然後重新整理許可權,不重啟db應該也可以解決。
查官方文檔又發現5.6版本新加的欄位password_expired用來控制密碼到期。
看下官方文檔
mysql> GRANT USAGE ON *.* TO 'francis'@'localhost' WITH MAX_QUERIES_PER_HOUR 100;mysql> GRANT USAGE ON *.* TO 'francis'@'localhost' WITH MAX_CONNECTIONS_PER_HOUR 0;
The server stores resource limits for an account in the user table row corresponding to the account. The max_questions, max_updates, and max_connections columns store the per-hour limits, and the max_user_connections column stores the MAX_USER_CONNECTIONS limit.