Controlling access.
WHAT A USER IS DEFINED BY
A name and a host pattern together.
WHY THAT SURPRISES PEOPLE
The same name from different hosts is a different account.
WHAT PRIVILEGES CAN BE GRANTED AT
The whole server A database A table A column
WHAT TO GRANT
The minimum the application needs.
WHAT A WEB APPLICATION USUALLY NEEDS
Select, insert, update and delete, on its own database.
WHAT IT USUALLY DOES NOT NEED
Creating or dropping tables Access to other databases Administrative privileges
WHY THAT MATTERS
An injection flaw is limited by what the account can do.
WHAT TO CREATE SEPARATELY
An account for migrations, with schema privileges, used only when applying them.
WHY SEPARATE
The running application then cannot alter its own structure.
WHAT TO AVOID
Using the root account in applications Wildcard host patterns Sharing one account between applications
WHY WILDCARD HOSTS MATTER
They permit connection from anywhere the network allows.
WHAT TO REVIEW PERIODICALLY
Every account, its host pattern, and its privileges.
WHAT TO REMOVE
Accounts nobody can identify.
WHAT TO ROTATE
Passwords, particularly after anyone leaves.