CREATE USER 'username'@'host' IDENTIFIED BY 'password';
→ Creates a new user.GRANT privileges ON database.table TO 'username'@'host';
→ Assigns permissions.REVOKE privileges ON database.table FROM 'username'@'host';
→ Removes permissions.DROP USER 'username'@'host';
→ Deletes a user.Let's create a new user named "john_doe" and grant them read-only access to a database called "company_db".
CREATE USER 'john_doe'@'localhost' IDENTIFIED BY 'securepass123';
GRANT SELECT ON company_db.* TO 'john_doe'@'localhost';
FLUSH PRIVILEGES;
CREATE USER
→ Creates a new user with a password.GRANT SELECT
→ Gives permission to only read data from company_db
.FLUSH PRIVILEGES
→ Refreshes MySQL to apply changes.MySQL User Management plays a crucial role in database security. By carefully assigning permissions, database administrators can control access, prevent data breaches, and ensure smooth database operations.