How can we set up a MySQL User account by using SQL GRANT statement?

MySQLMySQLi Database

We can also add user account by using GRANT SQL command. It can be illustrated by using the following example −

Example

In this example, we will add user Zara with password zara123 for a particular database,

which is named as TUTORIALS.

root@host# mysql -u root -p password;
Enter password:*******
mysql> use mysql;
Database changed

mysql> GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP
   -> ON TUTORIALS.*
   -> TO 'zara'@'localhost'
   -> IDENTIFIED BY 'zara123';

The above statements will also create an entry in the MySQL database table called as a user.

raja
Published on 21-Feb-2018 10:37:57
Advertisements