2004-07-08 15:54:07 +02:00
|
|
|
SET NAMES binary;
|
2004-10-20 14:04:43 +02:00
|
|
|
drop database if exists mysqltest;
|
2005-03-27 15:46:06 +02:00
|
|
|
drop database if exists mysqltest_1;
|
2003-07-22 22:00:51 +02:00
|
|
|
delete from mysql.user where user like 'mysqltest\_%';
|
|
|
|
delete from mysql.db where user like 'mysqltest\_%';
|
2004-10-20 14:04:43 +02:00
|
|
|
delete from mysql.tables_priv where user like 'mysqltest\_%';
|
|
|
|
delete from mysql.columns_priv where user like 'mysqltest\_%';
|
2003-07-22 22:00:51 +02:00
|
|
|
flush privileges;
|
|
|
|
grant all privileges on `my\_%`.* to mysqltest_1@localhost with grant option;
|
|
|
|
select current_user();
|
|
|
|
current_user()
|
|
|
|
mysqltest_1@localhost
|
2003-07-22 22:21:23 +02:00
|
|
|
grant all privileges on `my\_1`.* to mysqltest_2@localhost with grant option;
|
|
|
|
grant all privileges on `my_%`.* to mysqltest_3@localhost with grant option;
|
2004-06-16 05:18:20 +02:00
|
|
|
ERROR 42000: Access denied for user 'mysqltest_1'@'localhost' to database 'my_%'
|
2003-07-22 22:21:23 +02:00
|
|
|
show grants for mysqltest_1@localhost;
|
|
|
|
Grants for mysqltest_1@localhost
|
|
|
|
GRANT USAGE ON *.* TO 'mysqltest_1'@'localhost'
|
|
|
|
GRANT ALL PRIVILEGES ON `my\_%`.* TO 'mysqltest_1'@'localhost' WITH GRANT OPTION
|
|
|
|
show grants for mysqltest_2@localhost;
|
|
|
|
Grants for mysqltest_2@localhost
|
|
|
|
GRANT USAGE ON *.* TO 'mysqltest_2'@'localhost'
|
|
|
|
GRANT ALL PRIVILEGES ON `my\_1`.* TO 'mysqltest_2'@'localhost' WITH GRANT OPTION
|
2003-07-22 22:00:51 +02:00
|
|
|
show grants for mysqltest_3@localhost;
|
2003-07-22 22:21:23 +02:00
|
|
|
ERROR 42000: There is no such grant defined for user 'mysqltest_3' on host 'localhost'
|
2003-07-22 22:00:51 +02:00
|
|
|
delete from mysql.user where user like 'mysqltest\_%';
|
|
|
|
delete from mysql.db where user like 'mysqltest\_%';
|
|
|
|
flush privileges;
|
2005-03-27 15:46:06 +02:00
|
|
|
create database mysqltest_1;
|
|
|
|
grant all privileges on `mysqltest\_1`.* to mysqltest_1@localhost with grant option;
|
|
|
|
select current_user();
|
|
|
|
current_user()
|
|
|
|
mysqltest_1@localhost
|
|
|
|
show databases;
|
|
|
|
Database
|
|
|
|
mysqltest_1
|
|
|
|
test
|
|
|
|
grant all privileges on `mysqltest_1`.* to mysqltest_1@localhost with grant option;
|
|
|
|
ERROR 42000: Access denied for user 'mysqltest_1'@'localhost' to database 'mysqltest_1'
|
|
|
|
show grants for mysqltest_1@localhost;
|
|
|
|
Grants for mysqltest_1@localhost
|
|
|
|
GRANT USAGE ON *.* TO 'mysqltest_1'@'localhost'
|
|
|
|
GRANT ALL PRIVILEGES ON `mysqltest\_1`.* TO 'mysqltest_1'@'localhost' WITH GRANT OPTION
|
|
|
|
delete from mysql.user where user like 'mysqltest\_%';
|
|
|
|
delete from mysql.db where user like 'mysqltest\_%';
|
|
|
|
drop database mysqltest_1;
|
|
|
|
flush privileges;
|
2004-10-20 14:04:43 +02:00
|
|
|
create database mysqltest;
|
|
|
|
grant INSERT, SELECT on mysqltest.* to mysqltest_1@localhost;
|
|
|
|
flush privileges;
|
|
|
|
use mysqltest;
|
|
|
|
create table t1 (id int primary key, data varchar(255));
|
|
|
|
show grants for current_user();
|
|
|
|
Grants for mysqltest_1@localhost
|
|
|
|
GRANT USAGE ON *.* TO 'mysqltest_1'@'localhost'
|
|
|
|
GRANT SELECT, INSERT ON `mysqltest`.* TO 'mysqltest_1'@'localhost'
|
|
|
|
insert into t1 values (1, 'I can''t change it!');
|
|
|
|
update t1 set data='I can change it!' where id = 1;
|
|
|
|
ERROR 42000: Access denied for user 'mysqltest_1'@'localhost' to database 'mysqltest'
|
|
|
|
insert into t1 values (1, 'XXX') on duplicate key update data= 'I can change it!';
|
|
|
|
ERROR 42000: Access denied for user 'mysqltest_1'@'localhost' to database 'mysqltest'
|
|
|
|
select * from t1;
|
|
|
|
id data
|
|
|
|
1 I can't change it!
|
|
|
|
drop table t1;
|
|
|
|
delete from mysql.user where user like 'mysqltest\_%';
|
|
|
|
delete from mysql.db where user like 'mysqltest\_%';
|
|
|
|
flush privileges;
|
2004-12-31 11:52:14 +01:00
|
|
|
create table t1 (a int, b int);
|
|
|
|
grant select (a) on t1 to mysqltest_1@localhost with grant option;
|
|
|
|
grant select (a,b) on t1 to mysqltest_2@localhost;
|
|
|
|
ERROR 42000: SELECT command denied to user 'mysqltest_1'@'localhost' for column 'b' in table 't1'
|
|
|
|
grant select on t1 to mysqltest_3@localhost;
|
|
|
|
ERROR 42000: SELECT command denied to user 'mysqltest_1'@'localhost' for table 't1'
|
|
|
|
drop table t1;
|
|
|
|
delete 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;
|
|
|
|
drop database mysqltest;
|
|
|
|
use test;
|
2005-03-03 01:30:24 +01:00
|
|
|
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';
|
|
|
|
show grants for current_user();
|
|
|
|
Grants for mysqltest_1@127.0.0.0/255.0.0.0
|
|
|
|
GRANT USAGE ON *.* TO 'mysqltest_1'@'127.0.0.0/255.0.0.0'
|
|
|
|
GRANT ALL PRIVILEGES ON `mysqltest_1`.`t1` TO 'mysqltest_1'@'127.0.0.0/255.0.0.0'
|
|
|
|
select * from t1;
|
|
|
|
i
|
|
|
|
1
|
|
|
|
2
|
|
|
|
3
|
|
|
|
REVOKE ALL ON mysqltest_1.t1 FROM mysqltest_1@'127.0.0.0/255.0.0.0';
|
|
|
|
drop table mysqltest_1.t1;
|
|
|
|
drop database mysqltest_1;
|