Create a New User and Grant Permissions in MySQL

Date posted : 23/01/2019

Create a New User and Grant Permissions in MySQL

MySQL

MySQL, the most popular Open Source SQL database management system, is developed, distributed, and supported by Oracle Corporation.

Step 1: A new user can be created within the MySQL shell, using the following statement:

CREATE USER 'pheonix'@'localhost' IDENTIFIED BY 'password';

This will create a new user named ‘pheonix’ without any permissions.

Step 2: To give full access to all databases for the pheonix user, run the following statement:

GRANT ALL PRIVILEGES ON * . * TO 'pheonix'@'localhost';

Step 3:Then run following statement to reload all the privileges:

FLUSH PRIVILEGES;

Step 4: To give access to a specific database for the new user, run the following statement:

GRANT ALL PRIVILEGES ON database . * TO 'pheonix'@'localhost';

Step 5: To revoke access:

REVOKE ALL PRIVILEGES ON database.* FROM 'pheonix'@'localhost';

Thank you! for using PHEONIX SOLUTIONS.

You find this tutorial helpful? Share with your friends to keep it alive. Be the first to comment, we value your suggestions. For further queries please comment below.


admin

Our team has expertise across software and web development, WordPress, e-commerce, mobile applications, UI/UX, cloud and infrastructure, DevOps, CI/CD, API integration, security, testing, automation, and technical support. The team also works with AI-based software solutions, LLMs, AI workflows, AI agents, and intelligent application development to help businesses automate processes and build smarter digital solutions. We focus on developing, deploying, maintaining, and optimising secure, scalable, and reliable technology solutions while helping businesses adopt modern technologies and drive digital transformation.

Leave a Reply

Scroll to Top