MySQL – Should Each Web App User Have a MySQL User Account

MySQL

The thought occurred to me recently, but I have a suspicion the idea might be insane. A couple of benefits I'm perceiving are:

  • facilitate automated logging via triggers
  • control mysql connections on a per-(web-application-)user level

Obviously this would yield me a ridiculously long table of users, but any penalties of that aren't clear to me yet: the User table is properly indexed for O(Log(n)) single-user lookups.

Best Answer

What type of logging would you be looking at gaining? What I do in my application is an audit table that tracks application user, application command, and result (among other things). This, along with another audit table that tracks individual table changes, provides all the logging we need per user.

You could also set up a connection pool in your application to control connections per application.

At first blush, I think trying to manage so many users is a burden that outweighs any possible benefits.