GRANT USAGE ON *.* TO testuser17@localhost WITH MAX_QUERIES_PER_HOUR 3;
FLUSH USER_RESOURCES;
# Establish connection testuser17 (user=testuser17)
connect(localhost,testuser17,,test,MYSQL_PORT,MYSQL_SOCK);
# Switch to connection testuser17
SELECT 'First', USER();
First	USER()
First	testuser17@localhost
SELECT 'Second', USER();
Second	USER()
Second	testuser17@localhost
SELECT 'Third', USER();
Third	USER()
Third	testuser17@localhost
# ---- Expect here 'max_questions' limit exceeded -----------
SELECT 'Forth', USER();
ERROR 42000: User 'testuser17' has exceeded the 'max_questions' resource (current value: 3)
# Switch to connection default
FLUSH USER_RESOURCES;
# Establish connection testuser17_1 (user=testuser17)
connect(localhost,testuser17,,test,MYSQL_PORT,MYSQL_SOCK);
# Switch to connection testuser17_1
SELECT 'First', USER();
First	USER()
First	testuser17@localhost
SELECT 'Second', USER();
Second	USER()
Second	testuser17@localhost
SELECT 'Third', USER();
Third	USER()
Third	testuser17@localhost
# ---- Expect here 'max_questions' limit exceeded -----------
SELECT 'Forth', USER();
ERROR 42000: User 'testuser17' has exceeded the 'max_questions' resource (current value: 3)
# Switch to connection default
DROP USER testuser17@localhost;
GRANT USAGE ON *.* TO testuser18@localhost WITH MAX_QUERIES_PER_HOUR 3;
FLUSH USER_RESOURCES;
# Establish connection testuser18 (user=testuser18)
connect(localhost,testuser18,,test,MYSQL_PORT,MYSQL_SOCK);
# Switch to connection testuser18
SELECT 'First', USER();
First	USER()
First	testuser18@localhost
SELECT 'Second', USER();
Second	USER()
Second	testuser18@localhost
SELECT 'Third', USER();
Third	USER()
Third	testuser18@localhost
# ---- Expect here 'max_questions' limit exceeded -----------
SELECT 'Forth', USER();
ERROR 42000: User 'testuser18' has exceeded the 'max_questions' resource (current value: 3)
# Switch to connection default
FLUSH USER_RESOURCES;
# With additional connection for testuser18
# Establish connection testuser18_1 (user=testuser18)
connect(localhost,testuser18,,test,MYSQL_PORT,MYSQL_SOCK);
# Switch to connection testuser18_1
SELECT 'First', USER();
First	USER()
First	testuser18@localhost
SELECT 'Second', USER();
Second	USER()
Second	testuser18@localhost
SELECT 'Third', USER();
Third	USER()
Third	testuser18@localhost
# ---- Expect here 'max_questions' limit exceeded -----------
SELECT 'Forth', USER();
ERROR 42000: User 'testuser18' has exceeded the 'max_questions' resource (current value: 3)
# Switch to connection default
DROP USER testuser18@localhost;
GRANT USAGE ON *.* TO testuser19@localhost WITH MAX_QUERIES_PER_HOUR 3;
FLUSH USER_RESOURCES;
# Establish connection testuser19 (user=testuser19)
connect(localhost,testuser19,,test,MYSQL_PORT,MYSQL_SOCK);
# Switch to connection default
FLUSH USER_RESOURCES;
# Switch to connection testuser19
SELECT 'First', USER();
First	USER()
First	testuser19@localhost
SELECT 'Second', USER();
Second	USER()
Second	testuser19@localhost
SELECT 'Third', USER();
Third	USER()
Third	testuser19@localhost
# ---- Expect here 'max_questions' limit exceeded -----------
SELECT 'Forth', USER();
ERROR 42000: User 'testuser19' has exceeded the 'max_questions' resource (current value: 3)
# Switch to connection default
DROP USER testuser19@localhost;
GRANT USAGE ON *.* TO testuser21@localhost WITH MAX_QUERIES_PER_HOUR 3;
FLUSH USER_RESOURCES;
# Establish connection testuser21 (user=testuser21)
connect(localhost,testuser21,,test,MYSQL_PORT,MYSQL_SOCK);
SELECT 'Zero', USER();
Zero	USER()
Zero	testuser21@localhost
# Switch to connection default
FLUSH USER_RESOURCES;
# Switch to connection testuser21
SELECT 'First', USER();
First	USER()
First	testuser21@localhost
SELECT 'Second', USER();
Second	USER()
Second	testuser21@localhost
SELECT 'Third', USER();
Third	USER()
Third	testuser21@localhost
# ---- Expect here 'max_questions' limit exceeded -----------
SELECT 'Forth', USER();
ERROR 42000: User 'testuser21' has exceeded the 'max_questions' resource (current value: 3)
# Switch to connection default
DROP USER testuser21@localhost;
FLUSH USER_RESOURCES;
GRANT USAGE ON *.* TO testuser20@localhost WITH MAX_QUERIES_PER_HOUR 3;
# Establish connection testuser20 (user=testuser20)
connect(localhost,testuser20,,test,MYSQL_PORT,MYSQL_SOCK);
# Switch to connection testuser20
USE information_schema;
# Establish connection testuser20 (user=testuser20)
connect(localhost,testuser20,,test,MYSQL_PORT,MYSQL_SOCK);
# Switch to connection testuser20
SELECT 'First', USER();
First	USER()
First	testuser20@localhost
SELECT 'Second', USER();
Second	USER()
Second	testuser20@localhost
SELECT 'Third', USER();
ERROR 42000: User 'testuser20' has exceeded the 'max_questions' resource (current value: 3)
# ---- Expect here 'max_questions' limit exceeded -----------
SELECT 'Forth', USER();
ERROR 42000: User 'testuser20' has exceeded the 'max_questions' resource (current value: 3)
# Switch to connection default
DROP USER testuser20@localhost;