Skip to content
Advertisement

How can I define a SQL-query whitelist for a database user in MySQL?

I want limit the database access for a client. How can I define a explicit white list of SQL queries, witch can only execute a database user?

Advertisement

Answer

You would do the following:

  1. Remove read access from all tables for the user.
  2. Define views for each of the allowed queries.
  3. Be sure that the security for the views is declared as DEFINER rather than INVOKER.

Voila! The user has access to the views, but not to the underlying tables.

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement