

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What is the MySQL user creation script?
First, create a user and password using CREATE command. The syntax is as follows.
CREATE USER 'yourUserName'@'localhost' IDENTIFIED BY 'yourPassword';
The syntax to give all privileges of the specific database to the user is as follows.
GRANT ALL PRIVILEGES ON yourDatabaseName . * TO 'yourUserName'@'localhost';
Now you can implement the above syntaxes to create a user and grant all privileges.
Step 1 − Create a user
The query is as follows.
mysql> create user 'Adam Smith'@'localhost' IDENTIFIED BY 'Adam123456'; Query OK, 0 rows affected (0.29 sec)
Step 2 − Grant all privileges to the user.
The query is as follows.
mysql> GRANT ALL PRIVILEGES ON test . * TO 'Adam Smith'@'localhost'; Query OK, 0 rows affected (0.19 sec)
To cross check the user is created or not, you can use the MySQL.user table. The query is as follows.
mysql> select user,host from MySQL.user;
The following is the output.
+------------------+-----------+ | user | host | +------------------+-----------+ | Manish | % | | User2 | % | | mysql.infoschema | % | | mysql.session | % | | mysql.sys | % | | root | % | | Adam Smith | localhost | | User1 | localhost | | am | localhost | +------------------+-----------+ 9 rows in set (0.00 sec)
Look at the above sample output, the user Adam Smith is present in the MySQL.user table.
- Related Questions & Answers
- What is process creation in Operating Systems?
- What is Shell Script?
- What is the similarity between prepared statements and MySQL user variables?
- What are the properties of MySQL user variables?
- Execute a script when a user is pressing a key in HTML?
- Execute a script when the media is paused either by the user or programmatically in HTML?
- Execute a script when the element gets user input in HTML?
- How to get the creation date of a MySQL table?
- What is user-defined signal handler?
- What is User Acceptance Testing (UAT)?
- What is the user interface and operating system interface?
- What is Pre-Request Script in Postman?
- How do I get the creation date of a MySQL table?
- What do you mean by default MySQL database for the user?
- What is a User Datagram Protocol (UDP)?
Advertisements