The following situation is a bit confusing:
MariaDB [(none)]> CREATE USER 'obj_stk_sequence'@'localhost'; ERROR 1396 (HY000): Operation CREATE USER failed for 'obj_stk_sequence'@'localhost' MariaDB [(none)]> drop user obj_stk_sequence; ERROR 1396 (HY000): Operation DROP USER failed for 'obj_stk_sequence'@'%' MariaDB [(none)]> select current_user; +----------------+ | current_user | +----------------+ | root@localhost | +----------------+ 1 row in set (0.00 sec)
Sure, if the user already exists you are unable to
CREATE him, even if you’re root. And if he doesn’t exists, you can’t DROP him. But, WTF, it’s impossible that he
NOT EXISTS at the same time!
Uhm. Maybe it’s possible… if some system tables are damaged. In fact, I’ve
CHECKed all tables in
`mysql` and retried, and everything was ok:
MariaDB [(none)]> create user obj_stk_sequence; Query OK, 0 rows affected (0.00 sec) MariaDB [(none)]> drop user obj_stk_sequence; Query OK, 0 rows affected (0.00 sec)
I’ve noticed that if the
`mysql`.`proc` system table is corrupted, a clear error informs you about the problem. However, if you can’t
CREATE and DROP something, and you’re sure that you have all the privileges you need, I suggest that you
CHECK all the system tables.
To compose the query you need to
CHECK all the tables, just run this:
SELECT CONCAT('CHECK TABLE ', GROUP_CONCAT(CONCAT('`mysql`.`', `TABLE_NAME`, '`') SEPARATOR ', '), ' EXTENDED;') FROM `information_schema`.`TABLES` WHERE `TABLE_SCHEMA` = 'mysql';
Then, just copy and paste the result.
Please note that you can’t do this automagically with a Stored Procedure, because the
CHECK command is not supported for Prepared Statements.