Best Practice

suggest change

Limit root (and any other SUPER-privileged user) to

GRANT ... TO root@localhost ...

That prevents access from other servers. You should hand out SUPER to very few people, and they should be aware of their responsibility. The application should not have SUPER.

Limit application logins to the one database it uses:

GRANT ... ON dbname.* ...

That way, someone who hacks into the application code can’t get past dbname. This can be further refined via either of these:

GRANT SELECT ON dbname.* ...    -- "read only"
GRANT ... ON dbname.tblname ... -- "just one table"

The read-only account may also need safer extras such as:

GRANT SELECT, CREATE TEMPORARY TABLES ON dbname.* ...    -- "read only"

There is no absolute security. You can still do a few things to slow mistakes and attackers down.

In rare cases, the application may need something available only to root. Do that in a stored procedure created by root with SQL SECURITY DEFINER. That exposes only what the procedure does, for example one action on one table.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents