Monday, December 9, 2013

HOW TO CREATE USER IN MYSQL STEP by STEP

Hello,

In this tutorial I will show you how you can create a user account in mysql and assign permission to that account according to your need.

1. Open up your command prompt

2. Inside CMD navigate to bin folder inside your mysql and type mysql

Now mySql stores all the user information in a database called mysql, so we will use this database to create a account

3. Type use mysql ;

Now Inside this database there is a table name user, we will use this table. If you want to take a look of this table type select * from user \G ;


By using the above query you can see it list all the privileges you can set along with Host,User and Password

4. Now in order to create a user type the following query

insert into user (Host,User,Password,create_privs,delete_priv,update_priv,insert_priv) values ('localhost','Ali',Password("f00"),'Y','Y','Y','Y');

Now to describe the above query

As you can see I used 4 types of privileges and set them to yes, all the remaining privileges will set to No by default. You can specify fields according to your requirement.

Now for the password, I used a built in function name Password(), This function is use to decrypt our password, as you can see the below figure although our password is f00 but it is listed as a complex number

5. Last but not least, we have create the account but it is not active yet to make it active the following

 FLUSH PRIVILEGES;


This will change the update the privileges and you can use the newly created account.

If you have any further queries than please do comment.

Thanks 

No comments:

Post a Comment