MySQL would you please DROP USER IF EXISTS!?
MySQL can drop almost anything conditionally (e.g. databases, tables, procedures ...), but a user.
So if you have a DB bootstrap script that removes pesky default anonymous users, you probably want to do something like:
DROP USER ''@'localhost';
Now run it again on the same DB and you probably know what happens.
To my delight I found this little workaround gem by Steve Bearman from a April 2006 MySQL thread still working like a charm (tested on MySql 5.5). So now instead you do:
GRANT USAGE ON *.* TO ''@'localhost';
DROP USER ''@'localhost';
And voilá.
Written by Daniel Tralamazza
Related protips
1 Response
Thanks! It actually works with any user. Very handy for automatic provisioning!
over 1 year ago
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Mysql
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#