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.
💻 Live Code Editor
This page's programs are ready here — run them, edit them, and learn. No installation needed.
Powered by OneCompiler. The code loads into the editor automatically — press Run to see the output. If the editor does not open, open it in a new tab.