This write-up will present the tactic for creating a brand new database person in MySQL.
How one can Create/Make a New MySQL Database Person?
Take a look at the below-given directions to create a brand new database person in MySQL:
- Join with the MySQL server by way of the default person “root” by offering its password.
- Run the “CREATE USER ‘<username>’@’localhost’ IDENTIFIED BY ‘password’;” command.
- Grant permissions utilizing the “GRANT ALL PRIVILEGES ON *.* TO ‘<USERNAME>’@’localhost’ WITH GRANT OPTION;” command.
- Then, flush privileges.
- Show all database customers record for verification.
Step 1: Entry MySQL Databases
Initially, launch the Home windows terminal after which hook up with the MySQL server by way of the offered command:
Right here:
- “-u” represents the username.
- “root” is our database username.
- “-p” choice signifies the person password.
When the above-stated command is executed, it’s a must to specify the password:
Step 2: Create New Person
Now, use the offered command to make a brand new person within the MySQL database:
CREATE USER ‘tester’@’localhost’ IDENTIFIED BY ‘tester123@’;
Within the above command:
- “CREATE USER” question is used for creating/making a brand new person.
- “tester” is our new username, and “‘@’localhost” signifies making a person regionally.
- “IDENTIFIED BY” choice is utilized for specifying the password for a selected person.
From the given output, the “Question OK,……” signifies that the brand new person has been created efficiently:
Step 3: Grant Privileges
Subsequent, grant the privileges to the newly created person by operating the “GRANT ALL PRIVILEGES” question:
GRANT ALL PRIVILEGES ON *.* TO ‘tester’@’localhost’ WITH GRANT OPTION;
Right here:
- “GRANT ALL PRIVILEGES” grants all kinds of permissions to the person.
- “ON *.*” denotes that the grant permissions are utilized to the database and tables that may be accessed.
- “tester’@’localhost’ WITH GRANT OPTION” exhibits that each one privileges are assigned to offered username when a selected username is related by way of the native host:
Step 4: Activate Privileges
Then, run the “FLUSH PRIVILEGES” command to activate all newly granted permission to the person earlier than they entry them:
Step 5: Confirm New Person
To make sure that the brand new database person is created or not, run the “SELECT” command:
Choose person from mysql.person;
As you may see, the newly created database person exists within the database record:
Step 6: Join With MySQL Server With New Person
Now, entry the MySQL server with the brand new person by specifying the corresponding credentials:
That was all about creating a brand new database person in MySQL.
Conclusion
To create a brand new database person in MySQL, first, join with the MySQL server by way of the default person “root” by offering its password. Then, use the “CREATE USER ‘<username>’@’localhost’ IDENTIFIED BY ‘password’;” command. After that, grant privileges by way of the “GRANT ALL PRIVILEGES ON *.* TO ‘<USERNAME>’@’localhost’ WITH GRANT OPTION;” command. Lastly, activate all added privileges by using the “FLUSH PRIVILEGES” command. For verification, record all database customers. This write-up offered the process to create a brand new database person in MySQL.