1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380
|
CREATE USER unlocked_user@localhost IDENTIFIED BY 'pas';
SELECT account_locked FROM mysql.user
WHERE user='unlocked_user' and host = 'localhost';
account_locked
N
SELECT CURRENT_USER();
CURRENT_USER()
unlocked_user@localhost
# lock the user in the database
UPDATE mysql.user SET account_locked='Y'
WHERE user='unlocked_user' and host = 'localhost';
# without FLUSH the field has no effect
# must not throw an error
SELECT CURRENT_USER();
CURRENT_USER()
unlocked_user@localhost
FLUSH PRIVILEGES;
# existing connections continue as before even after flush
# must not throw an error
SELECT CURRENT_USER();
CURRENT_USER()
unlocked_user@localhost
# Lowercase 'y' should disable login as well
UPDATE mysql.user SET account_locked='y'
WHERE user='unlocked_user' and host = 'localhost';
FLUSH PRIVILEGES;
connect(localhost,unlocked_user,pas,test,MASTER_PORT,MASTER_SOCKET);
ERROR HY000: Access denied for user 'unlocked_user'@'localhost'. Account is locked.
# new connections are blocked
connect(localhost,unlocked_user,pas,test,MASTER_PORT,MASTER_SOCKET);
ERROR HY000: Access denied for user 'unlocked_user'@'localhost'. Account is locked.
# unlock the user using ALTER USER command
ALTER USER unlocked_user@localhost ACCOUNT UNLOCK;
SELECT account_locked FROM mysql.user
WHERE user = 'unlocked_user' and host = 'localhost';
account_locked
N
# connection should work now
SELECT CURRENT_USER();
CURRENT_USER()
unlocked_user@localhost
# lock the user account using ALTER USER command
ALTER USER unlocked_user@localhost ACCOUNT LOCK;
SELECT account_locked FROM mysql.user
WHERE user = 'unlocked_user' and host = 'localhost';
account_locked
Y
# connection should not work
connect(localhost,unlocked_user,pas,test,MASTER_PORT,MASTER_SOCKET);
ERROR HY000: Access denied for user 'unlocked_user'@'localhost'. Account is locked.
# create another user
CREATE USER unlocked_user2@localhost IDENTIFIED BY 'pas';
# newly created user should be able to log in
SELECT CURRENT_USER();
CURRENT_USER()
unlocked_user2@localhost
# toogle access permission with one SQL statement
ALTER USER unlocked_user@localhost,
unlocked_user2@localhost ACCOUNT UNLOCK;
SELECT user, account_locked FROM mysql.user
WHERE (user = 'unlocked_user' and host = 'localhost') or
(user = 'unlocked_user2' and host = 'localhost') ORDER BY user;
user account_locked
unlocked_user N
unlocked_user2 N
# unlocked_user2 should be able to log in
SELECT CURRENT_USER();
CURRENT_USER()
unlocked_user2@localhost
# unlocked_user should be able to log in
SELECT CURRENT_USER();
CURRENT_USER()
unlocked_user@localhost
# Basic SHOW CREATE USER
# Should appear without ACCOUNT UNLOCK
SHOW CREATE USER unlocked_user@localhost;
CREATE USER for unlocked_user@localhost
CREATE USER `unlocked_user`@`localhost` IDENTIFIED WITH '<default_authentication>' AS '<non-deterministic-password-hash>' REQUIRE NONE PASSWORD EXPIRE DEFAULT ACCOUNT UNLOCK PASSWORD HISTORY DEFAULT PASSWORD REUSE INTERVAL DEFAULT PASSWORD REQUIRE CURRENT DEFAULT
ALTER USER unlocked_user@localhost ACCOUNT LOCK;
# Should appear with ACCOUNT LOCK
SHOW CREATE USER unlocked_user@localhost;
CREATE USER for unlocked_user@localhost
CREATE USER `unlocked_user`@`localhost` IDENTIFIED WITH '<default_authentication>' AS '<non-deterministic-password-hash>' REQUIRE NONE PASSWORD EXPIRE DEFAULT ACCOUNT LOCK PASSWORD HISTORY DEFAULT PASSWORD REUSE INTERVAL DEFAULT PASSWORD REQUIRE CURRENT DEFAULT
# roll back changes
DROP USER unlocked_user@localhost;
DROP USER unlocked_user2@localhost;
# Create anonymous user
CREATE USER ''@localhost IDENTIFIED BY 'pass';
SELECT CURRENT_USER();
CURRENT_USER()
@localhost
DROP USER ''@localhost;
# Create anonymous user - explicit UNLOCK
CREATE USER ''@localhost IDENTIFIED BY 'pass' ACCOUNT UNLOCK;
SELECT CURRENT_USER();
CURRENT_USER()
@localhost
DROP USER ''@localhost;
# Create anonymous user - LOCK
CREATE USER ''@localhost IDENTIFIED BY 'pass' ACCOUNT LOCK;
connect(localhost, ,pass,test,MASTER_PORT,MASTER_SOCKET);
ERROR HY000: Access denied for user '(null)'@'localhost'. Account is locked.
DROP USER ''@localhost;
# Disabling anonymous user
CREATE USER ''@localhost IDENTIFIED BY 'pass';
ALTER USER ''@localhost ACCOUNT LOCK;
connect(localhost, ,pass,test,MASTER_PORT,MASTER_SOCKET);
ERROR HY000: Access denied for user '(null)'@'localhost'. Account is locked.
DROP USER ''@localhost;
# Enabling anonymous user
CREATE USER ''@localhost IDENTIFIED BY 'pass' ACCOUNT LOCK;
ALTER USER ''@localhost ACCOUNT UNLOCK;
SELECT CURRENT_USER();
CURRENT_USER()
@localhost
DROP USER ''@localhost;
# Expiring password and disabing anynymous user
CREATE USER ''@localhost IDENTIFIED BY 'pass';
ALTER USER ''@localhost PASSWORD EXPIRE ACCOUNT LOCK;
ERROR HY000: The password for anonymous user cannot be expired.
DROP USER ''@localhost;
# Login as anonymous user and try to manipulate mysql.user table
# and users.
CREATE user ''@localhost IDENTIFIED BY 'pass';
CREATE USER 'unlocked_user'@localhost IDENTIFIED BY 'pass';
UPDATE mysql.user SET account_locked='Y'
WHERE user='unlocked_user' and host = 'localhost';
ERROR 42000: UPDATE command denied to user ''@'localhost' for table 'user'
ALTER USER unlocked_user@localhost ACCOUNT LOCK;
ERROR 42000: Access denied; you need (at least one of) the CREATE USER privilege(s) for this operation
DROP USER unlocked_user@localhost;
DROP USER ''@localhost;
# Create stored procedure and users for test
CREATE USER u1@localhost IDENTIFIED BY 'pass';
CREATE USER u2@localhost IDENTIFIED BY 'pass';
GRANT ALL ON *.* TO u1@localhost;
CREATE TABLE mysql.t1(counter INT)|
INSERT INTO mysql.t1 VALUES(0)|
CREATE DEFINER = u1@localhost PROCEDURE mysql.p1()
BEGIN
UPDATE mysql.t1 SET counter = counter + 1;
SELECT counter FROM mysql.t1;
END|
CALL mysql.p1();
counter
1
GRANT EXECUTE ON PROCEDURE mysql.p1 TO u2@localhost;
ALTER USER u1@localhost ACCOUNT LOCK;
# Login for u1@localhost should fail
connect(localhost,u1,pass,test,MASTER_PORT,MASTER_SOCKET);
ERROR HY000: Access denied for user 'u1'@'localhost'. Account is locked.
# Login as u2 and run stored procedure as u1
SELECT CURRENT_USER();
CURRENT_USER()
u2@localhost
CALL mysql.p1();
counter
2
# Locked_connects STATUS VARIABLE
FLUSH STATUS;
CREATE USER 'u3'@'localhost' IDENTIFIED BY 'pass' ACCOUNT LOCK;
SHOW STATUS LIKE 'Locked_connects';
Variable_name Value
Locked_connects 0
ERROR HY000: Access denied for user 'u3'@'localhost'. Account is locked.
ERROR HY000: Access denied for user 'u3'@'localhost'. Account is locked.
ERROR HY000: Access denied for user 'u3'@'localhost'. Account is locked.
ERROR HY000: Access denied for user 'u3'@'localhost'. Account is locked.
ERROR HY000: Access denied for user 'u3'@'localhost'. Account is locked.
ERROR HY000: Access denied for user 'u3'@'localhost'. Account is locked.
ERROR HY000: Access denied for user 'u3'@'localhost'. Account is locked.
ERROR HY000: Access denied for user 'u3'@'localhost'. Account is locked.
ERROR HY000: Access denied for user 'u3'@'localhost'. Account is locked.
ERROR HY000: Access denied for user 'u3'@'localhost'. Account is locked.
SHOW STATUS LIKE 'Locked_connects';
Variable_name Value
Locked_connects 10
FLUSH STATUS;
# Invalid SQL syntax should fail
CREATE USER u1@localhost REQUIRE NONE ACCOUNT LOCK WITH MAX_QUERIES_PER_HOUR 100;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WITH MAX_QUERIES_PER_HOUR 100' at line 1
# CREATE USER SQL syntax check
DROP USER u1@localhost;
Warnings:
Warning 4005 User 'u1'@'localhost' is referenced as a definer account in a stored routine.
CREATE USER u1@localhost REQUIRE NONE WITH MAX_QUERIES_PER_HOUR 100 ACCOUNT LOCK;
Warnings:
Warning 4005 User 'u1'@'localhost' is referenced as a definer account in a stored routine.
SHOW CREATE USER u1@localhost;
CREATE USER for u1@localhost
CREATE USER `u1`@`localhost` IDENTIFIED WITH '<default_authentication>' REQUIRE NONE WITH MAX_QUERIES_PER_HOUR 100 PASSWORD EXPIRE DEFAULT ACCOUNT LOCK PASSWORD HISTORY DEFAULT PASSWORD REUSE INTERVAL DEFAULT PASSWORD REQUIRE CURRENT DEFAULT
# ALTER USER correct SQL syntax 1
ALTER USER u1@localhost PASSWORD EXPIRE ACCOUNT UNLOCK;
SHOW CREATE USER u1@localhost;
CREATE USER for u1@localhost
CREATE USER `u1`@`localhost` IDENTIFIED WITH '<default_authentication>' REQUIRE NONE WITH MAX_QUERIES_PER_HOUR 100 PASSWORD EXPIRE ACCOUNT UNLOCK PASSWORD HISTORY DEFAULT PASSWORD REUSE INTERVAL DEFAULT PASSWORD REQUIRE CURRENT DEFAULT
# ALTER USER correct SQL syntax 2
ALTER USER u1@localhost ACCOUNT LOCK PASSWORD EXPIRE;
SHOW CREATE USER u1@localhost;
CREATE USER for u1@localhost
CREATE USER `u1`@`localhost` IDENTIFIED WITH '<default_authentication>' REQUIRE NONE WITH MAX_QUERIES_PER_HOUR 100 PASSWORD EXPIRE ACCOUNT LOCK PASSWORD HISTORY DEFAULT PASSWORD REUSE INTERVAL DEFAULT PASSWORD REQUIRE CURRENT DEFAULT
# ALTER USER correct SQL syntax 3
ALTER USER u1@localhost REQUIRE NONE WITH MAX_QUERIES_PER_HOUR 99 ACCOUNT UNLOCK PASSWORD EXPIRE NEVER;
SHOW CREATE USER u1@localhost;
CREATE USER for u1@localhost
CREATE USER `u1`@`localhost` IDENTIFIED WITH '<default_authentication>' REQUIRE NONE WITH MAX_QUERIES_PER_HOUR 99 PASSWORD EXPIRE ACCOUNT UNLOCK PASSWORD HISTORY DEFAULT PASSWORD REUSE INTERVAL DEFAULT PASSWORD REQUIRE CURRENT DEFAULT
# ALTER USER correct SQL syntax 4
ALTER USER u1@localhost REQUIRE NONE WITH MAX_QUERIES_PER_HOUR 98 PASSWORD EXPIRE INTERVAL 5 DAY ACCOUNT LOCK;
SHOW CREATE USER u1@localhost;
CREATE USER for u1@localhost
CREATE USER `u1`@`localhost` IDENTIFIED WITH '<default_authentication>' REQUIRE NONE WITH MAX_QUERIES_PER_HOUR 98 PASSWORD EXPIRE ACCOUNT LOCK PASSWORD HISTORY DEFAULT PASSWORD REUSE INTERVAL DEFAULT PASSWORD REQUIRE CURRENT DEFAULT
# ALTER USER invalid SQL syntax
ALTER USER u1@localhost ACCOUNT UNLOCK WITH MAX_QUERIES_PER_HOUR 97 PASSWORD EXPIRE;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WITH MAX_QUERIES_PER_HOUR 97 PASSWORD EXPIRE' at line 1
DROP USER u1@localhost;
Warnings:
Warning 4005 User 'u1'@'localhost' is referenced as a definer account in a stored routine.
# Duplicated ACCOUNT statement 1
CREATE USER u1@localhost IDENTIFIED BY 'PASS' ACCOUNT LOCK ACCOUNT UNLOCK;
Warnings:
Warning 4005 User 'u1'@'localhost' is referenced as a definer account in a stored routine.
SHOW CREATE USER u1@localhost;
CREATE USER for u1@localhost
CREATE USER `u1`@`localhost` IDENTIFIED WITH '<default_authentication>' AS '<non-deterministic-password-hash>' REQUIRE NONE PASSWORD EXPIRE DEFAULT ACCOUNT UNLOCK PASSWORD HISTORY DEFAULT PASSWORD REUSE INTERVAL DEFAULT PASSWORD REQUIRE CURRENT DEFAULT
DROP USER u1@localhost;
Warnings:
Warning 4005 User 'u1'@'localhost' is referenced as a definer account in a stored routine.
# Duplicated ACCOUNT statement 2
CREATE USER u1@localhost ACCOUNT UNLOCK ACCOUNT LOCK;
Warnings:
Warning 4005 User 'u1'@'localhost' is referenced as a definer account in a stored routine.
SHOW CREATE USER u1@localhost;
CREATE USER for u1@localhost
CREATE USER `u1`@`localhost` IDENTIFIED WITH '<default_authentication>' REQUIRE NONE PASSWORD EXPIRE DEFAULT ACCOUNT LOCK PASSWORD HISTORY DEFAULT PASSWORD REUSE INTERVAL DEFAULT PASSWORD REQUIRE CURRENT DEFAULT
DROP USER u1@localhost;
Warnings:
Warning 4005 User 'u1'@'localhost' is referenced as a definer account in a stored routine.
# Duplicated ACCOUNT statement 3
CREATE USER u1@localhost ACCOUNT LOCK PASSWORD EXPIRE ACCOUNT LOCK;
Warnings:
Warning 4005 User 'u1'@'localhost' is referenced as a definer account in a stored routine.
SHOW CREATE USER u1@localhost;
CREATE USER for u1@localhost
CREATE USER `u1`@`localhost` IDENTIFIED WITH '<default_authentication>' REQUIRE NONE PASSWORD EXPIRE ACCOUNT LOCK PASSWORD HISTORY DEFAULT PASSWORD REUSE INTERVAL DEFAULT PASSWORD REQUIRE CURRENT DEFAULT
# Duplicated ACCOUNT statement 4
ALTER USER u1@localhost IDENTIFIED BY 'PASS' ACCOUNT LOCK ACCOUNT UNLOCK;
SHOW CREATE USER u1@localhost;
CREATE USER for u1@localhost
CREATE USER `u1`@`localhost` IDENTIFIED WITH '<default_authentication>' AS '<non-deterministic-password-hash>' REQUIRE NONE PASSWORD EXPIRE DEFAULT ACCOUNT UNLOCK PASSWORD HISTORY DEFAULT PASSWORD REUSE INTERVAL DEFAULT PASSWORD REQUIRE CURRENT DEFAULT
# Duplicated ACCOUNT statement 5
ALTER USER u1@localhost ACCOUNT UNLOCK ACCOUNT LOCK;
SHOW CREATE USER u1@localhost;
CREATE USER for u1@localhost
CREATE USER `u1`@`localhost` IDENTIFIED WITH '<default_authentication>' AS '<non-deterministic-password-hash>' REQUIRE NONE PASSWORD EXPIRE DEFAULT ACCOUNT LOCK PASSWORD HISTORY DEFAULT PASSWORD REUSE INTERVAL DEFAULT PASSWORD REQUIRE CURRENT DEFAULT
# Duplicated ACCOUNT statement 6
ALTER USER u1@localhost ACCOUNT LOCK PASSWORD EXPIRE ACCOUNT LOCK;
SHOW CREATE USER u1@localhost;
CREATE USER for u1@localhost
CREATE USER `u1`@`localhost` IDENTIFIED WITH '<default_authentication>' AS '<non-deterministic-password-hash>' REQUIRE NONE PASSWORD EXPIRE ACCOUNT LOCK PASSWORD HISTORY DEFAULT PASSWORD REUSE INTERVAL DEFAULT PASSWORD REQUIRE CURRENT DEFAULT
# Duplicated ACCOUNT statement 7
ALTER USER u1@localhost PASSWORD EXPIRE ACCOUNT LOCK PASSWORD EXPIRE NEVER;
SHOW CREATE USER u1@localhost;
CREATE USER for u1@localhost
CREATE USER `u1`@`localhost` IDENTIFIED WITH '<default_authentication>' AS '<non-deterministic-password-hash>' REQUIRE NONE PASSWORD EXPIRE ACCOUNT LOCK PASSWORD HISTORY DEFAULT PASSWORD REUSE INTERVAL DEFAULT PASSWORD REQUIRE CURRENT DEFAULT
# Duplicated ACCOUNT statement 8
ALTER USER u1@localhost PASSWORD EXPIRE NEVER ACCOUNT LOCK PASSWORD EXPIRE INTERVAL 5 DAY ACCOUNT LOCK;
SHOW CREATE USER u1@localhost;
CREATE USER for u1@localhost
CREATE USER `u1`@`localhost` IDENTIFIED WITH '<default_authentication>' AS '<non-deterministic-password-hash>' REQUIRE NONE PASSWORD EXPIRE ACCOUNT LOCK PASSWORD HISTORY DEFAULT PASSWORD REUSE INTERVAL DEFAULT PASSWORD REQUIRE CURRENT DEFAULT
# MySQL user table layout from the before ACCOUNT LOCK option
call mtr.add_suppression("Column count of mysql.* is wrong. "
"Expected .*, found .*. "
"The table is probably corrupted");
CREATE TABLE mysql.temp_user LIKE mysql.user;
INSERT INTO mysql.temp_user SELECT * FROM mysql.user;
ALTER TABLE mysql.user DROP COLUMN account_locked;
ALTER TABLE mysql.user DROP COLUMN create_role_priv;
ALTER TABLE mysql.user DROP COLUMN drop_role_priv;
CREATE USER backuser@localhost IDENTIFIED BY 'pass' ACCOUNT LOCK;
ERROR HY000: Column count of mysql.user is wrong. Expected 51, found 48. The table is probably corrupted
SELECT COUNT(*) FROM mysql.user WHERE (user = 'backuser' and host = 'localhost');
COUNT(*)
0
CREATE USER backuser@localhost IDENTIFIED BY 'pass' ACCOUNT UNLOCK;
ERROR HY000: Column count of mysql.user is wrong. Expected 51, found 48. The table is probably corrupted
SELECT COUNT(*) FROM mysql.user WHERE (user = 'backuser' and host = 'localhost');
COUNT(*)
0
CREATE USER backuser@localhost IDENTIFIED BY 'pass';
ERROR HY000: Column count of mysql.user is wrong. Expected 51, found 48. The table is probably corrupted
SELECT COUNT(*) FROM mysql.user WHERE (user = 'backuser' and host = 'localhost');
COUNT(*)
0
SELECT user, account_locked FROM mysql.user WHERE (user = 'backuser' and host = 'localhost');
ERROR 42S22: Unknown column 'account_locked' in 'field list'
ALTER USER backuser@localhost ACCOUNT LOCK;
ERROR HY000: Column count of mysql.user is wrong. Expected 51, found 48. The table is probably corrupted
ALTER USER backuser@localhost ACCOUNT UNLOCK;
ERROR HY000: Column count of mysql.user is wrong. Expected 51, found 48. The table is probably corrupted
DROP USER backuser@localhost;
ERROR HY000: Column count of mysql.user is wrong. Expected 51, found 48. The table is probably corrupted
DROP TABLE mysql.user;
ALTER TABLE mysql.temp_user RENAME mysql.user;
FLUSH PRIVILEGES;
# Check whether 'account' can be used as the identifier.
CREATE DATABASE account;
CREATE TABLE account.`account` (account text(20));
INSERT INTO `account`.account VALUES("account");
SELECT account FROM account.account WHERE account = 'account';
account
account
SET @account = "account_before";
CREATE PROCEDURE account.account(OUT ac CHAR(20))
BEGIN
SELECT account.`account`.account INTO ac FROM account.account;
END|
CALL account.account(@account);
SELECT @account;
@account
account
DROP DATABASE account;
CREATE USER ACCOUNT@localhost ACCOUNT LOCK;
DROP USER ACCOUNT@localhost;
DROP PROCEDURE mysql.p1;
DROP TABLE mysql.t1;
DROP USER u1@localhost;
DROP USER u2@localhost;
DROP USER u3@localhost;
#
# Bug #20814051 CREATE USER BINLOG EVENTS INCLUDE NEW ACCOUNT KEYWORD
#
CREATE USER u1 IDENTIFIED BY 'pass';
SHOW CREATE USER u1;
CREATE USER for u1@%
CREATE USER `u1`@`%` IDENTIFIED WITH '<default_authentication>' AS '<non-deterministic-password-hash>' REQUIRE NONE PASSWORD EXPIRE DEFAULT ACCOUNT UNLOCK PASSWORD HISTORY DEFAULT PASSWORD REUSE INTERVAL DEFAULT PASSWORD REQUIRE CURRENT DEFAULT
ALTER USER u1 ACCOUNT LOCK;
SHOW CREATE USER u1;
CREATE USER for u1@%
CREATE USER `u1`@`%` IDENTIFIED WITH '<default_authentication>' AS '<non-deterministic-password-hash>' REQUIRE NONE PASSWORD EXPIRE DEFAULT ACCOUNT LOCK PASSWORD HISTORY DEFAULT PASSWORD REUSE INTERVAL DEFAULT PASSWORD REQUIRE CURRENT DEFAULT
DROP USER u1;
# Restart server.
TRUNCATE TABLE mysql.general_log;
--------------- general log ---------------------------------------
SET @old_log_output= @@global.log_output;
SET @old_general_log= @@global.general_log;
SET @old_general_log_file= @@global.general_log_file;
SET GLOBAL general_log_file = '.../log/rewrite_general.log';
SET GLOBAL log_output = 'FILE,TABLE';
SET GLOBAL general_log= 'ON';
CREATE USER u1 IDENTIFIED BY 'pass';
CREATE USER u2 IDENTIFIED BY 'pass' ACCOUNT LOCK;
CREATE USER u3 IDENTIFIED BY 'pass' ACCOUNT UNLOCK;
ALTER USER u1 IDENTIFIED BY 'pass';
ALTER USER u1 IDENTIFIED BY 'pass' ACCOUNT LOCK;
ALTER USER u1 IDENTIFIED BY 'pass' ACCOUNT UNLOCK;
#
# BUG #20996273 ALTER USER REWRITE CAUSES DIFFERENCES ON SLAVE
#
ALTER USER u2 IDENTIFIED BY 'pass';
Show what is logged:
------ rewrite ------
SELECT argument FROM mysql.general_log WHERE argument LIKE 'CREATE USER %' AND
command_type NOT LIKE 'Prepare';
argument
CREATE USER 'u1'@'%' IDENTIFIED BY <secret>
CREATE USER 'u2'@'%' IDENTIFIED BY <secret> ACCOUNT LOCK
CREATE USER 'u3'@'%' IDENTIFIED BY <secret> ACCOUNT UNLOCK
SELECT argument FROM mysql.general_log WHERE argument LIKE 'ALTER USER %'AND
command_type NOT LIKE 'Prepare';
argument
ALTER USER 'u1'@'%' IDENTIFIED BY <secret>
ALTER USER 'u1'@'%' IDENTIFIED BY <secret> ACCOUNT LOCK
ALTER USER 'u1'@'%' IDENTIFIED BY <secret> ACCOUNT UNLOCK
ALTER USER 'u2'@'%' IDENTIFIED BY <secret>
------ done ------
DROP USER u1, u2, u3;
SET GLOBAL general_log_file= @old_general_log_file;
SET GLOBAL general_log= @old_general_log;
SET GLOBAL log_output= @old_log_output;
TRUNCATE TABLE mysql.general_log;
|