![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to create MySQL user with limited privileges?
To create MySQL user with limited privileges, following is the syntax −
CREATE USER 'yourUserName'@'yourHostName' IDENTIFIED BY 'yourPassword';
Following is the syntax to set limited privileges for user −
GRANT SELECT, INSERT, UPDATE, etc. REFERENCES ON yourDatabaseName.* TO 'yourUserName'@'yourHostName';
Let us implement the above syntaxes in order to create a MySQL user with limited privileges −
mysql> CREATE USER 'David'@'localhost' IDENTIFIED BY 'david'; Query OK, 0 rows affected (0.20 sec) mysql> GRANT SELECT, INSERT, UPDATE, DELETE, ALTER, CREATE, REFERENCES ON test.* TO 'David'@'localhost'; Query OK, 0 rows affected (0.21 sec)
Let us check the user has been created with name ‘David’ or not.
mysql> select user, host from MySQL.user;
This will produce the following output −
+------------------+-----------+ | user | host | +------------------+-----------+ | Bob | % | | User2 | % | | mysql.infoschema | % | | mysql.session | % | | mysql.sys | % | | root | % | | @UserName@ | localhost | | Adam Smith | localhost | | David | localhost | | James | localhost | | John | localhost | | John Doe | localhost | | User1 | localhost | | am | localhost | | hbstudent | localhost | | mysql.infoschema | localhost | | mysql.session | localhost | +------------------+-----------+ 17 rows in set (0.00 sec)
Advertisements