Monday, June 9, 2025

Create a user in MySQL

To See All Articles About Technology: Index of Lessons in Technology

To create a new user in MySQL, follow these steps after logging into the MySQL prompt as root:


✅ Step-by-Step: Create a New User in MySQL

1. Login to MySQL

bash
mysql -u root -p

Enter the root password when prompted.


2. Create the User

sql
CREATE USER 'username'@'localhost' IDENTIFIED BY 'your_password';

✅ Example:

sql
CREATE USER 'ashish'@'localhost' IDENTIFIED BY 'StrongPass@123';

3. Grant Permissions

You can grant full privileges on a database like this:

sql
GRANT ALL PRIVILEGES ON your_database.* TO 'username'@'localhost';

✅ Example:

sql
GRANT ALL PRIVILEGES ON translation_app.* TO 'ashish'@'localhost';

If the database doesn't exist yet:

sql
CREATE DATABASE translation_app;

4. Apply Changes

sql
FLUSH PRIVILEGES;

✅ Verify:

sql
SELECT User, Host FROM mysql.user;

Let me know if you'd like to grant only read access, create the user for remote access, or anything more specific.

Tags: Technology,Database,

No comments:

Post a Comment