Grant least privilege: app user with SELECT/INSERT/UPDATE/DELETE on one database—not SUPER on production.
Create user and grant
CREATE USER 'app_rw'@'%' IDENTIFIED BY 'CHANGE_ME';
GRANT SELECT, INSERT, UPDATE, DELETE ON practice.* TO 'app_rw'@'%';
FLUSH PRIVILEGES;Use strong passwords and restrict host ('app'@'10.%') in production.
Show grants
SHOW GRANTS FOR CURRENT_USER();
Important interview questions and answers
- Q: FLUSH PRIVILEGES?
A: Reloads grant tables—needed after manual grant table edits. - Q: Root in app?
A: Never—compromise becomes full cluster control.
Self-check
- Minimum grants for app CRUD?
- Why not use root in Laravel .env?
Tip: App role: CRUD on one DB only—never SUPER.
Interview prep
- Least privilege?
App user limited to one database CRUD.
- GRANT?
Assigns privileges to user@host.