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

📄 grant2.test

📁 这是linux下运行的mysql软件包,可用于linux 下安装 php + mysql + apach 的网络配置
💻 TEST
📖 第 1 页 / 共 2 页
字号:
drop user 'mysqltest_1';## Cleanupdrop table t1, t2;## Add a stray recordinsert into mysql.db set user='mysqltest_1', db='%', host='%';flush privileges;--error 1141show grants for 'mysqltest_1';--error 1269revoke all privileges, grant option from 'mysqltest_1';drop user 'mysqltest_1';select host,db,user from mysql.db where user = 'mysqltest_1' order by host,db,user;## Add a stray recordinsert into mysql.tables_priv set host='%', db='test', user='mysqltest_1', table_name='t1';flush privileges;--error 1141show grants for 'mysqltest_1';drop user 'mysqltest_1';select host,db,user,table_name from mysql.tables_priv where user = 'mysqltest_1' order by host,db,user,table_name;## Add a stray recordinsert into mysql.columns_priv set host='%', db='test', user='mysqltest_1', table_name='t1', column_name='c1';flush privileges;--error 1141show grants for 'mysqltest_1';drop user 'mysqltest_1';select host,db,user,table_name,column_name from mysql.columns_priv where user = 'mysqltest_1' order by host,db,user,table_name,column_name;## Handle multi user listscreate user 'mysqltest_1', 'mysqltest_2', 'mysqltest_3';drop user 'mysqltest_1', 'mysqltest_2', 'mysqltest_3';create user 'mysqltest_1', 'mysqltest_2' identified by 'Mysqltest-2', 'mysqltest_3' identified by password 'fffffffffffffffffffffffffffffffffffffffff';rename user 'mysqltest_1' to 'mysqltest_1a', 'mysqltest_2' TO 'mysqltest_2a', 'mysqltest_3' TO 'mysqltest_3a';--error 1396drop user 'mysqltest_1', 'mysqltest_2', 'mysqltest_3';drop user 'mysqltest_1a', 'mysqltest_2a', 'mysqltest_3a';## Let one of multiple users failcreate user 'mysqltest_1', 'mysqltest_2', 'mysqltest_3';--error 1396create user 'mysqltest_1a', 'mysqltest_2', 'mysqltest_3a';--error 1396rename user 'mysqltest_1a' to 'mysqltest_1b', 'mysqltest_2a' TO 'mysqltest_2b', 'mysqltest_3a' TO 'mysqltest_3b';drop user 'mysqltest_1', 'mysqltest_2', 'mysqltest_3';--error 1396drop user 'mysqltest_1b', 'mysqltest_2b', 'mysqltest_3b';## Obsolete syntax has been droppedcreate user 'mysqltest_2' identified by 'Mysqltest-2';--error 1064drop user 'mysqltest_2' identified by 'Mysqltest-2';drop user 'mysqltest_2';## Strange user namescreate user '%@b'@'b';show grants for '%@b'@'b';grant select on mysql.* to '%@b'@'b';show grants for '%@b'@'b';rename user '%@b'@'b' to '%@a'@'a';--error 1141show grants for '%@b'@'b';show grants for '%@a'@'a';drop user '%@a'@'a';## CREATE USER privilege is enough#create user mysqltest_2@localhost;grant create user on *.* to mysqltest_2@localhost;connect (user3,localhost,mysqltest_2,,);connection user3;--error 1142select host,user,password from mysql.user where user like 'mysqltest_%' order by host,user,password;create user mysqltest_A@'%';rename user mysqltest_A@'%' to mysqltest_B@'%';drop user mysqltest_B@'%';disconnect user3;connection default;drop user mysqltest_2@localhost;## INSERT/UPDATE/DELETE is ok toocreate user mysqltest_3@localhost;grant INSERT,DELETE,UPDATE on mysql.* to mysqltest_3@localhost;connect (user4,localhost,mysqltest_3,,);connection user4;show grants;--error 1142select host,user,password from mysql.user where user like 'mysqltest_%' order by host,user,password;insert into mysql.user set host='%', user='mysqltest_B';create user mysqltest_A@'%';rename user mysqltest_B@'%' to mysqltest_C@'%';drop user mysqltest_C@'%';drop user mysqltest_A@'%';disconnect user4;connection default;drop user mysqltest_3@localhost;## Bug #3309: Test IP addresses with netmaskset @@sql_mode='';create database mysqltest_1;create table mysqltest_1.t1 (i int);insert into mysqltest_1.t1 values (1),(2),(3);GRANT ALL ON mysqltest_1.t1 TO mysqltest_1@'127.0.0.0/255.0.0.0';connect (n1,127.0.0.1,mysqltest_1,,mysqltest_1,$MASTER_MYPORT,$MASTER_MYSOCK);connection n1;show grants for current_user();select * from t1;disconnect n1;connection default;REVOKE ALL ON mysqltest_1.t1 FROM mysqltest_1@'127.0.0.0/255.0.0.0';delete from mysql.user where user like 'mysqltest\_1';flush privileges;drop table mysqltest_1.t1;## Bug #12302: 'SET PASSWORD = ...' didn't work if connecting hostname !=# hostname the current user is authenticated as. Note that a test for this# was also added to the test above.#grant all on mysqltest_1.* to mysqltest_1@'127.0.0.1';connect (b12302,127.0.0.1,mysqltest_1,,mysqltest_1,$MASTER_MYPORT,);connection b12302;select current_user();set password = password('changed');disconnect b12302;connection default;select host, length(password) from mysql.user where user like 'mysqltest\_1';revoke all on mysqltest_1.* from mysqltest_1@'127.0.0.1';delete from mysql.user where user like 'mysqltest\_1';flush privileges;grant all on mysqltest_1.* to mysqltest_1@'127.0.0.0/255.0.0.0';connect (b12302_2,127.0.0.1,mysqltest_1,,mysqltest_1,$MASTER_MYPORT,);connection b12302_2;select current_user();set password = password('changed');disconnect b12302_2;connection default;select host, length(password) from mysql.user where user like 'mysqltest\_1';revoke all on mysqltest_1.* from mysqltest_1@'127.0.0.0/255.0.0.0';delete from mysql.user where user like 'mysqltest\_1';flush privileges;drop database mysqltest_1;# But anonymous users can't change their passwordconnect (n5,localhost,test,,test,$MASTER_MYPORT,$MASTER_MYSOCK);connection n5;--error 1044set password = password("changed");disconnect n5;connection default;# Bug #12423 "Deadlock when doing FLUSH PRIVILEGES and GRANT in # multi-threaded environment". We should be able to execute FLUSH# PRIVILEGES and SET PASSWORD simultaneously with other account# management commands (such as GRANT and REVOKE) without causing# deadlocks. To achieve this we should ensure that all account# management commands take table and internal locks in the same order.connect (con2root,localhost,root,,);connect (con3root,localhost,root,,);# Check that we can execute FLUSH PRIVILEGES and GRANT simultaneously# This will check that locks are taken in proper order during both# user/db-level and table/column-level privileges reloading.connection default;lock table mysql.user write;connection con2root;send flush privileges;connection con3root;send grant all on *.* to 'mysqltest_1'@'localhost';connection default;unlock tables;connection con2root;reap;connection con3root;reap;# Check for simultaneous SET PASSWORD and REVOKE.connection default;lock table mysql.user write;connection con2root;send set password for 'mysqltest_1'@'localhost' = password('');connection con3root;send revoke all on *.* from 'mysqltest_1'@'localhost';connection default;unlock tables;connection con2root;reap;connection con3root;reap;connection default;# Clean-updrop user 'mysqltest_1'@'localhost';disconnect con2root;disconnect con3root;# End of 4.1 tests## Bug#17279 user with no global privs and with create#           priv in db can create databases#create database TESTDB;create table t2(a int);create temporary table t1 as select * from mysql.user;delete from mysql.user where host='localhost';INSERT INTO mysql.user VALUES('%','mysqltest_1',password('password'),'N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','','','','',0,0,0,0);INSERT INTO mysql.db VALUES('%','TESTDB','mysqltest_1','Y','Y','Y','Y','Y','Y','N','Y','Y','Y','Y','N','Y','Y','Y','Y','N');FLUSH PRIVILEGES;connect (con1,localhost,mysqltest_1,password,TESTDB);# The user mysqltest_1 should only be allowed access to# database TESTDB, not TEStdb# On system with "lowercase names" we get error "1007: Can't create db..."--error 1044, 1007create database TEStdb;# Clean-upconnection default;delete from mysql.user;delete from mysql.db where host='%' and user='mysqltest_1' and db='TESTDB';insert into mysql.user select * from t1;drop table t1, t2;drop database TESTDB;flush privileges;

⌨️ 快捷键说明

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