MySQL + SQL · Lesson 106
MySQL Users and Privileges
Managing Users
MySQL lets the DBA create users and give each one only the privileges they need — a core security practice.
Create User & Grant
CREATE USER 'teacher'@'localhost' IDENTIFIED BY 'pass123';
GRANT SELECT, UPDATE ON school.* TO 'teacher'@'localhost';
FLUSH PRIVILEGES;
SHOW GRANTS FOR 'teacher'@'localhost';
Principle of Least Privilege
Give each user only the minimum access they need. A fee clerk should not be able to DROP tables.
Summary
- CREATE USER makes accounts; GRANT assigns privileges.
- Follow least privilege — minimum access per user.