Add a MySQL User, Simple & Reliable

on Monday, 01 August 2011.

I've found the easiest most reliable way to add a MySQL user with all priviledges is with a simple query.


CREATE USER 'db_username'@'localhost';
GRANT ALL PRIVILEGES ON db_name.* TO 'db_username'@'localhost';
SET PASSWORD FOR 'db_username'@'localhost' = PASSWORD('password');

All you need to do is replace 'db_username', 'db_name', and 'password' with your relevant database details, execute the MySQL and presto!

blog comments powered by Disqus