Adding Users – MySQL

Using the default root user for all your applications is fine as long as you don’t plan on exposing any of said applications to the internet or any other people that aren’t you. Adding extra users to your MySQL server is a piece of cake and I personally like to have a different user for each application that I have.

The first thing we want to do is create a database for our user to use. So open up your MySQL command prompt and create a new database like so:


Now we have a database we can create a new user for it. Again in the command prompt type out the following:

CREATE USER 'testuser'@'localhost' IDENTIFIED BY 'p@ssword';
GRANT ALL PRIVILEGES ON testdb . * TO 'testuser':@'localhost'

What we have done here is create a new user and then allowed that user to do whatever they like in the database testdb, be it creating deleting or modifying content.

Now we have a brand new user for our application. If the application is going to be web facing I would suggest a strong password as you will only need to use that password once and store it in the configuration of the app.


One thought on “Adding Users – MySQL”

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s