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


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.

Updated on: 20-Jun-2020

100 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements