How to create a New Database-user and Grand Permissions – MySQL

We already discussed about the creation of MySQL DB and DB users. Here I am explaining the commands which are using to Grand Privileges to users for accessing the Databases in your server.

Enter the mysql prompt by following the step below:

# mysql -u root -p

It then prompts for password. Enter the MySQL root password.

Example:

[email protected] [/]# mysql -u root -p
Enter password:

1, Command to Grand All privileges on DB for a user.

mysql> GRANT ALL PRIVILEGES ON database.* to 'username'@'localhost' IDENTIFIED BY 'password' WITH GRANT OPTION;

Refer the example below for more details:

mysql> GRANT ALL PRIVILEGES ON crybit_wp.* to 'crybit_wp'@'localhost' IDENTIFIED BY 'with_the_new_password' WITH GRANT OPTION;

2, how to add SELECT privileges to a user using GRANT.

mysql> GRANT SELECT ON database.* to 'username'@'localhost' IDENTIFIED BY 'password';

3, how to add a selection of privileges to a user using GRANT.

mysql> GRANT SELECT, INSERT, DELETE ON database.* to 'username'@'localhost' IDENTIFIED BY 'password';

That’s it 🙂 🙂

Related:
How to create/restore MySQL dump/backup of all the databases.
How to create a database and database user from command line
Reset mysql root password from command line
How to allow mysql client to access remote mysql databases

Post navigation

Arunlal Ashok

Linux Systems Architect at Endurance International Group. I know her (Linux) since many years. Linux lover. Like to play on Linux console. I started this blog to share and discuss Linux thoughts.

Always happy for an open discussion! Write to arun (@) crybit (dot) com. Check about me for more details. About this blog and our strong members, check The team CryBit.com

One thought on “How to create a New Database-user and Grand Permissions – MySQL

  1. It is important to have the database and that is why the creating the database is also necessary and for this, a user has to be skilled and also to make the grand permissions on the MySql is important to have. There are many processes by which a database can be created and the given process can also be applied.

Leave a Reply

Your email address will not be published. Required fields are marked *