Search This Blog

Saturday 31 January 2015

MySQL Tips & Tricks - WIP

Fix for MySQL ERROR 1396 (Operation DROP USER failed ... )

As of 5.0.37 version, it is not possible to issue DROP USER command for a non-existent user.

Line 2 in the following workaround fixes the problem:

1
2
3
4
5
6
CREATE DATABASE IF NOT EXISTS some_database;
GRANT SELECT ON *.* TO 'some_user'@'localhost';
DROP USER 'some_user'@'localhost';
CREATE USER 'some_user'@'localhost' IDENTIFIED BY 'xxxxxxx';
GRANT SELECT, INSERT, UPDATE, DELETE ON some_database.* TO 'some_user'@'localhost';
FLUSH PRIVILEGES;