2016-01-18 01:16:59 +01:00
|
|
|
--source include/not_embedded.inc
|
|
|
|
|
2024-05-23 03:54:14 +02:00
|
|
|
--disable_cursor_protocol
|
2018-11-24 14:13:41 +01:00
|
|
|
select priv into @root_priv from mysql.global_priv where user='root' and host='localhost';
|
2024-05-23 03:54:14 +02:00
|
|
|
--enable_cursor_protocol
|
2018-11-24 14:13:41 +01:00
|
|
|
|
2016-01-18 01:16:59 +01:00
|
|
|
select * from mysql.user where user = 'root' and host = 'localhost';
|
|
|
|
--echo # Test syntax
|
|
|
|
--echo #
|
|
|
|
--echo # These 2 selects should have no changes from the first one.
|
|
|
|
alter user CURRENT_USER;
|
|
|
|
select * from mysql.user where user = 'root' and host = 'localhost';
|
|
|
|
alter user CURRENT_USER();
|
|
|
|
select * from mysql.user where user = 'root' and host = 'localhost';
|
|
|
|
|
|
|
|
create user foo;
|
|
|
|
select * from mysql.user where user = 'foo';
|
|
|
|
alter user foo;
|
|
|
|
select * from mysql.user where user = 'foo';
|
|
|
|
|
2020-02-28 18:59:01 +01:00
|
|
|
--echo #
|
|
|
|
--echo # Test READ_ONLY privilege works correctly with a read only database.
|
|
|
|
--echo #
|
|
|
|
|
2016-01-18 01:16:59 +01:00
|
|
|
SET @start_read_only = @@global.read_only;
|
|
|
|
SET GLOBAL read_only=1;
|
|
|
|
grant create user on *.* to foo;
|
|
|
|
|
2020-02-28 18:59:01 +01:00
|
|
|
--echo # Currently no READ_ONLY ADMIN privileges.
|
2016-01-18 01:16:59 +01:00
|
|
|
connect (a, localhost, foo);
|
|
|
|
select @@global.read_only;
|
|
|
|
|
|
|
|
--error ER_OPTION_PREVENTS_STATEMENT
|
|
|
|
alter user foo;
|
|
|
|
|
2020-02-28 18:59:01 +01:00
|
|
|
--echo # Grant READ_ONLY ADMIN privilege to the user.
|
2016-01-18 01:16:59 +01:00
|
|
|
connection default;
|
2020-02-28 18:59:01 +01:00
|
|
|
grant READ_ONLY ADMIN on *.* to foo;
|
2016-01-18 01:16:59 +01:00
|
|
|
|
2020-02-28 18:59:01 +01:00
|
|
|
--echo # We now have READ_ONLY ADMIN privilege. We should be able to run alter user.
|
2016-01-18 01:16:59 +01:00
|
|
|
connect (b, localhost, foo);
|
|
|
|
alter user foo;
|
|
|
|
|
|
|
|
connection default;
|
|
|
|
SET GLOBAL read_only = @start_read_only;
|
|
|
|
|
2020-02-28 18:59:01 +01:00
|
|
|
|
|
|
|
--echo #
|
2016-01-18 01:16:59 +01:00
|
|
|
--echo # Test inexistant user.
|
2020-02-28 18:59:01 +01:00
|
|
|
--echo #
|
|
|
|
|
2016-01-18 01:16:59 +01:00
|
|
|
--error ER_CANNOT_USER
|
|
|
|
alter user boo;
|
|
|
|
--echo #--warning ER_CANNOT_USER
|
2020-02-10 21:19:37 +01:00
|
|
|
alter user if exists boo;
|
2016-01-18 01:16:59 +01:00
|
|
|
|
2020-02-28 18:59:01 +01:00
|
|
|
|
|
|
|
--echo #
|
2016-03-07 23:35:03 +01:00
|
|
|
--echo # Test password related altering.
|
2020-02-28 18:59:01 +01:00
|
|
|
--echo #
|
|
|
|
|
2016-01-18 01:16:59 +01:00
|
|
|
alter user foo identified by 'something';
|
|
|
|
select * from mysql.user where user = 'foo';
|
|
|
|
|
|
|
|
alter user foo identified by 'something2';
|
|
|
|
select * from mysql.user where user = 'foo';
|
|
|
|
|
|
|
|
alter user foo identified by password '*88C89BE093D4ECF72D039F62EBB7477EA1FD4D63';
|
|
|
|
select * from mysql.user where user = 'foo';
|
|
|
|
|
2020-07-16 08:31:59 +02:00
|
|
|
alter user foo identified by password 'invalid';
|
|
|
|
select * from mysql.user where user = 'foo';
|
|
|
|
|
2018-10-17 12:48:13 +02:00
|
|
|
--error ER_CANNOT_USER
|
2016-01-18 01:16:59 +01:00
|
|
|
alter user foo identified with 'somecoolplugin';
|
2018-10-17 12:48:13 +02:00
|
|
|
show warnings;
|
|
|
|
|
|
|
|
alter user foo identified with 'mysql_old_password';
|
2016-01-18 01:16:59 +01:00
|
|
|
select * from mysql.user where user = 'foo';
|
|
|
|
|
2018-10-17 12:48:13 +02:00
|
|
|
alter user foo identified with 'mysql_old_password' using '0123456789ABCDEF';
|
2016-01-18 01:16:59 +01:00
|
|
|
select * from mysql.user where user = 'foo';
|
|
|
|
|
2020-02-28 18:59:01 +01:00
|
|
|
|
|
|
|
--echo #
|
2016-03-07 23:35:03 +01:00
|
|
|
--echo # Test ssl related altering.
|
2020-02-28 18:59:01 +01:00
|
|
|
--echo #
|
|
|
|
|
2016-03-07 23:35:03 +01:00
|
|
|
alter user foo identified by 'something' require SSL;
|
|
|
|
select * from mysql.user where user = 'foo';
|
|
|
|
|
|
|
|
alter user foo identified by 'something' require X509;
|
|
|
|
select * from mysql.user where user = 'foo';
|
|
|
|
|
|
|
|
alter user foo identified by 'something'
|
|
|
|
require cipher 'text' issuer 'foo_issuer' subject 'foo_subject';
|
|
|
|
select * from mysql.user where user = 'foo';
|
|
|
|
|
2020-02-28 18:59:01 +01:00
|
|
|
|
|
|
|
--echo #
|
2016-01-18 01:16:59 +01:00
|
|
|
--echo # Test resource limits altering.
|
2020-02-28 18:59:01 +01:00
|
|
|
--echo #
|
|
|
|
|
2016-01-18 01:16:59 +01:00
|
|
|
alter user foo with MAX_QUERIES_PER_HOUR 10
|
|
|
|
MAX_UPDATES_PER_HOUR 20
|
|
|
|
MAX_CONNECTIONS_PER_HOUR 30
|
|
|
|
MAX_USER_CONNECTIONS 40;
|
|
|
|
select * from mysql.user where user = 'foo';
|
|
|
|
drop user foo;
|
2018-10-17 12:48:13 +02:00
|
|
|
|
2022-01-21 12:40:20 +01:00
|
|
|
--echo #
|
|
|
|
--echo # Bug #29882299: ALTER USER ... IDENTIFIED WITH ... BY ... SHOULD BE A PRIVILEGED OPERATION
|
|
|
|
--echo #
|
|
|
|
create user foo@localhost;
|
|
|
|
--connect x,localhost,foo
|
|
|
|
--error ER_SPECIFIC_ACCESS_DENIED_ERROR
|
|
|
|
alter user current_user identified with 'something';
|
|
|
|
--connection default
|
|
|
|
--disconnect x
|
|
|
|
drop user foo@localhost;
|
2022-01-30 09:46:52 +01:00
|
|
|
|
2018-11-24 14:13:41 +01:00
|
|
|
update mysql.global_priv set priv=@root_priv where user='root' and host='localhost';
|