⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 user_limits.test

📁 这是linux下运行的mysql软件包,可用于linux 下安装 php + mysql + apach 的网络配置
💻 TEST
字号:
## Test behavior of various per-account limits (aka quotas)## Requires privileges to be enabled-- source include/not_embedded.inc# Prepare play-ground --disable_warningsdrop table if exists t1;--enable_warningscreate table t1 (i int);# Just be sure that nothing will bother usdelete from mysql.user where user like 'mysqltest\_%';delete from mysql.db where user like 'mysqltest\_%';delete from mysql.tables_priv where user like 'mysqltest\_%';delete from mysql.columns_priv where user like 'mysqltest\_%';flush privileges;# Limits doesn't work with prepared statements (yet)--disable_ps_protocol# Test of MAX_QUERIES_PER_HOUR limitgrant usage on *.* to mysqltest_1@localhost with max_queries_per_hour 2;# This ensures that counters are reset and makes test scheduling independentflush user_resources;connect (mqph, localhost, mysqltest_1,,);connection mqph;select * from t1;select * from t1;--error 1226select * from t1;connect (mqph2, localhost, mysqltest_1,,);connection mqph2;--error 1226select * from t1;# cleanupconnection default;drop user mysqltest_1@localhost;disconnect mqph;disconnect mqph2;# Test of MAX_UPDATES_PER_HOUR limitgrant usage on *.* to mysqltest_1@localhost with max_updates_per_hour 2;flush user_resources;connect (muph, localhost, mysqltest_1,,);connection muph;select * from t1;select * from t1;select * from t1;delete from t1;delete from t1;--error 1226delete from t1;select * from t1;connect (muph2, localhost, mysqltest_1,,);connection muph2;--error 1226delete from t1;select * from t1;# Cleanupconnection default;drop user mysqltest_1@localhost;disconnect muph;disconnect muph2;# Test of MAX_CONNECTIONS_PER_HOUR limitgrant usage on *.* to mysqltest_1@localhost with max_connections_per_hour 2;flush user_resources;connect (mcph1, localhost, mysqltest_1,,);connection mcph1;select * from t1;connect (mcph2, localhost, mysqltest_1,,);connection mcph2;select * from t1;--replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK--error 1226connect (mcph3, localhost, mysqltest_1,,);# Old connection is still okselect * from t1;# Let us try to close old connections and try again. This will also test that# counters are not thrown away if there are no connections for this user.disconnect mcph1;disconnect mcph2;--replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK--error 1226connect (mcph3, localhost, mysqltest_1,,);# Cleanupconnection default;drop user mysqltest_1@localhost;# Test of MAX_USER_CONNECTIONS limit# We need this to reset internal mqh_used variableflush privileges;grant usage on *.* to mysqltest_1@localhost with max_user_connections 2;flush user_resources;connect (muc1, localhost, mysqltest_1,,);connection muc1;select * from t1;connect (muc2, localhost, mysqltest_1,,);connection muc2;select * from t1;--replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK--error 1226connect (muc3, localhost, mysqltest_1,,);# Closing of one of connections should helpdisconnect muc1;connect (muc3, localhost, mysqltest_1,,);select * from t1;# Changing of limit should also help (and immediately) connection default;grant usage on *.* to mysqltest_1@localhost with max_user_connections 3;flush user_resources;connect (muc4, localhost, mysqltest_1,,);connection muc4;select * from t1;--replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK--error 1226connect (muc5, localhost, mysqltest_1,,);# Clean upconnection default;disconnect muc2;disconnect muc3;disconnect muc4;drop user mysqltest_1@localhost;# Now let us test interaction between global and per-account# max_user_connections limitsselect @@session.max_user_connections, @@global.max_user_connections;# Local max_user_connections variable can't be set directly# since this limit is per-account--error 1229set session max_user_connections= 2; # But it is ok to set global max_user_connectionsset global max_user_connections= 2; select @@session.max_user_connections, @@global.max_user_connections;# Let us check that global limit worksgrant usage on *.* to mysqltest_1@localhost;flush user_resources;connect (muca1, localhost, mysqltest_1,,);connection muca1;select @@session.max_user_connections, @@global.max_user_connections;connect (muca2, localhost, mysqltest_1,,);connection muca2;select * from t1;--replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK--error 1203connect (muca3, localhost, mysqltest_1,,);# Now we are testing that per-account limit prevails over gloabl limitconnection default;grant usage on *.* to mysqltest_1@localhost with max_user_connections 3;flush user_resources;connect (muca3, localhost, mysqltest_1,,);connection muca3;select @@session.max_user_connections, @@global.max_user_connections;--replace_result $MASTER_MYPORT MYSQL_PORT $MASTER_MYSOCK MYSQL_SOCK--error 1226connect (muca4, localhost, mysqltest_1,,);# Cleanupconnection default;disconnect muca1;disconnect muca2;disconnect muca3;set global max_user_connections= 0; drop user mysqltest_1@localhost;--enable_ps_protocol# Final cleanupdrop table t1;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -