Set Up MySQL User Account 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: 2020-06-20T13:16:33+05:30

150 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements