🚀
20. Users and Permissions
++++
Data Engineering
May 2026×8 min read

Create MySQL users, grant and revoke privileges, and apply least privilege for safer database access.

20. Users and Permissions

Driptanil Datta
Driptanil DattaSoftware Developer

Users and Permissions

Database users control who can connect and what they can do. Good permission design protects data from accidental or unauthorized changes.

Create a user

CREATE USER "report_user"@"localhost"
IDENTIFIED BY "strong_password_here";

The part before @ is the username. The part after @ is the host the user can connect from.

Grant read-only access

GRANT SELECT
ON companydb.*
TO "report_user"@"localhost";

This user can read every table in companydb, but cannot insert, update, delete, or alter tables.

Grant access to one table

GRANT SELECT, INSERT
ON companydb.customers
TO "app_writer"@"localhost";

Use table-level grants when a user only needs part of a database.

Apply privilege changes

Modern MySQL applies many grant changes immediately, but FLUSH PRIVILEGES is still common after direct privilege table changes.

FLUSH PRIVILEGES;

Revoke permissions

REVOKE INSERT
ON companydb.customers
FROM "app_writer"@"localhost";

Remove a user:

DROP USER "report_user"@"localhost";

Check grants

SHOW GRANTS FOR "report_user"@"localhost";

Least privilege

Least privilege means each user gets only the permissions needed for their job.

User typeTypical permissions
Dashboard userSELECT only
Application writerSELECT, INSERT, UPDATE, maybe DELETE
Migration userSchema change permissions such as CREATE, ALTER, DROP
AdminFull privileges, used rarely

Avoid using the root user in applications. Create specific users for applications, dashboards, and maintenance tasks.

Drip

Driptanil Datta

Software Developer

Building full-stack systems, one commit at a time. This blog is a centralized learning archive for developers.

Legal Notes
Disclaimer

The content provided on this blog is for educational and informational purposes only. While I strive for accuracy, all information is provided "as is" without any warranties of completeness, reliability, or accuracy. Any action you take upon the information found on this website is strictly at your own risk.

Copyright & IP

Certain technical content, interview questions, and datasets are curated from external educational sources to provide a centralized learning resource. Respect for original authorship is maintained; no copyright infringement is intended. All trademarks, logos, and brand names are the property of their respective owners.

System Operational

© 2026 Driptanil Datta. All rights reserved.