Create MySQL User with all Permissions

By sean on May 04, 2012

The below snippet will create a MySQL user and grant them all permissions on the given database. The % wildcard identifier will allow this particular user to be accessible via any hostname. While the * wildcard will grant the user access to all tables within the supplied database. You can change either to match your specific needs.

GRANT ALL ON `database`.* TO 'user'@'%' IDENTIFIED BY 'password';

GRANT ALL ON `database`.`table` TO 'user'@'192.168.1.%' IDENTIFIED BY 'password';

Comments

Sign in to comment.
Hawkee   -  Nov 03, 2012

Thank you. Since snippets are our biggest draw I think they deserve a full page.

 Respond  
sean   -  Nov 03, 2012

I've found myself coming to this post a couple of times! :P

PS: Love the new snippet layout; much cleaner.

 Respond  
Hawkee   -  Nov 01, 2012

Just used this today. Always a handy couple queries. I really should have them memorized by now though.

 Respond  
Hawkee   -  May 04, 2012

I can't tell you how many times I've had to look this up on Google. Very useful.

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.