Quy Truong
Quy Truong

Reputation: 413

Logging user action in mysql

I'm working with a big project that a lot people participate in. We use a same MySQL database for development. The question is how can I know who have done something (insert, update, delete, run query, etc...) on database, when have they done it and what have they done. Assuming that everyone have a different account.

Upvotes: 0

Views: 499

Answers (2)

user5478656
user5478656

Reputation: 276

You can use general logging.

It would log the details of the clients connect, disconnect and the queries run on the database.

To turn it on, set the following property in my.cnf:

general_log_file = /path/to/query.log
general_log      = 1

Or, you can set it from the console:

SET global general_log = 1;

Refer: http://dev.mysql.com/doc/refman/5.7/en/query-log.html

Upvotes: 1

Rob Wood
Rob Wood

Reputation: 415

You'll have to run through all your functions or procedures and adapt them to insert/update a "last editor" identifier, and add a field for that identifier to your tables. No easy way around that.

Upvotes: 1

Related Questions