T
T
tunelix2011-06-24 06:04:43
MySQL
tunelix, 2011-06-24 06:04:43

Is there a way to record all changes in a MYSQL database?

1. To be transparent
2. To be able to roll back

Maybe something like GIT for MYSQL?

Thanks :)

Answer the question

In order to leave comments, you need to log in

5 answer(s)
@
@sledopit, 2011-06-24
_

Turn on bin-logs and you will be happy. You can roll back in time to any moment, up to seconds.

S
sl_bug, 2011-06-24
@sl_bug

Just make your own triggers. For example like here - www.jasny.net/articles/versioning-mysql-data/

G
gro, 2011-06-24
@gro

To a question in such a general form, the only correct answer is binary logs.
Already from the specifics of the question itself, the decision may change.

X
xaker1, 2011-06-24
@xaker1

I agree with the use of triggers. You can roll back - there will be all information about changes in any table, as transparently as possible.
An example of using habrahabr.ru/blogs/mysql/121129/ .

T
Timur Shemsedinov, 2011-06-24
@MarcusAurelius

It’s also very good for transparency not to call sql statements from the code right away, but to make a layer in the form of your library of functions for accessing the database, then you can write all queries to the logs directly in the form of SQL statements (CREATE, ALTER, UPDATE, DELETE, INSERT .. .), in this form it is very convenient to edit the magazine, cut it into pieces, and upload it to the database. If every day the logs are written to a separate file, then it’s generally convenient: for backup and restoration, for synchronization with another database, for understanding what and how many requests the system makes, well, for optimization, I recommend writing the execution time there so that you can allocate long requests. MySQL has of course a built-in logging tool, in /etc/mysql/my.cnf there is a line "log = /var/log/mysql/mysql.log" and it is usually commented out. If you uncomment it, then it will not be a separate project that will be logged, and all databases on the server. Only slow queries "slow-queries=sloq.log" can be logged. We have already talked about binary logs and they are good because you can choose which database to log. But I prefer to write the logs myself, because. you can do some other additional operations on them, for example, parse and analyze, build statistics, identify errors and do something, in general, for transparency - you need your own layer, and I consider it bad form to call PDO or mysql_query directly from the program code . Even if you don’t have anything hung now, but at any moment you may want to hang something, believe me, when the system is a couple of years old and there are thousands of files in it, then such logging is indispensable for fixing a problem or finding an error. Even sometimes, in the form of a temporary patch, you can correct SQL statements before they are executed. Only slow queries "slow-queries=sloq.log" can be logged. We have already talked about binary logs and they are good because you can choose which database to log. But I prefer to write the logs myself, because. you can do some other additional operations on them, for example, parse and analyze, build statistics, identify errors and do something, in general, for transparency - you need your own layer, and I consider it bad form to call PDO or mysql_query directly from the program code . Even if you don’t have anything hung now, but at any moment you may want to hang something, believe me, when the system is a couple of years old and there are thousands of files in it, then such logging is indispensable for fixing a problem or finding an error. Even sometimes, in the form of a temporary patch, you can correct SQL statements before they are executed. Only slow queries "slow-queries=sloq.log" can be logged. We have already talked about binary logs and they are good because you can choose which database to log. But I prefer to write the logs myself, because. you can do some other additional operations on them, for example, parse and analyze, build statistics, identify errors and do something, in general, for transparency - you need your own layer, and I consider it bad form to call PDO or mysql_query directly from the program code . Even if you don’t have anything hung now, but at any moment you may want to hang something, believe me, when the system is a couple of years old and there are thousands of files in it, then such logging is indispensable for fixing a problem or finding an error. Even sometimes, in the form of a temporary patch, you can correct SQL statements before they are executed. We have already talked about binary logs and they are good because you can choose which database to log. But I prefer to write the logs myself, because. you can do some other additional operations on them, for example, parse and analyze, build statistics, identify errors and do something, in general, for transparency - you need your own layer, and I consider it bad form to call PDO or mysql_query directly from the program code . Even if you don’t have anything hung now, but at any moment you may want to hang something, believe me, when the system is a couple of years old and there are thousands of files in it, then such logging is indispensable for fixing a problem or finding an error. Even sometimes, in the form of a temporary patch, you can correct SQL statements before they are executed. We have already talked about binary logs and they are good because you can choose which database to log. But I prefer to write the logs myself, because. you can do some other additional operations on them, for example, parse and analyze, build statistics, identify errors and do something, in general, for transparency - you need your own layer, and I consider it bad form to call PDO or mysql_query directly from the program code . Even if you don’t have anything hung now, but at any moment you may want to hang something, believe me, when the system is a couple of years old and there are thousands of files in it, then such logging is indispensable for fixing a problem or finding an error. Even sometimes, in the form of a temporary patch, you can correct SQL statements before they are executed. But I prefer to write the logs myself, because. you can do some other additional operations on them, for example, parse and analyze, build statistics, identify errors and do something, in general, for transparency - you need your own layer, and I consider it bad form to call PDO or mysql_query directly from the program code . Even if you don’t have anything hung now, but at any moment you may want to hang something, believe me, when the system is a couple of years old and there are thousands of files in it, then such logging is indispensable for fixing a problem or finding an error. Even sometimes, in the form of a temporary patch, you can correct SQL statements before they are executed. But I prefer to write the logs myself, because. you can do some other additional operations on them, for example, parse and analyze, build statistics, identify errors and do something, in general, for transparency - you need your own layer, and I consider it bad form to call PDO or mysql_query directly from the program code . Even if you don’t have anything hung now, but at any moment you may want to hang something, believe me, when the system is a couple of years old and there are thousands of files in it, then such logging is indispensable for fixing a problem or finding an error. Even sometimes, in the form of a temporary patch, you can correct SQL statements before they are executed. for transparency, you need your own layer, and I consider it bad form to call PDO or mysql_query directly from the program code. Even if you don’t have anything hung now, but at any moment you may want to hang something, believe me, when the system is a couple of years old and there are thousands of files in it, then such logging is indispensable for fixing a problem or finding an error. Even sometimes, in the form of a temporary patch, you can correct SQL statements before they are executed. for transparency, you need your own layer, and I consider it bad form to call PDO or mysql_query directly from the program code. Even if you don’t have anything hung now, but at any moment you may want to hang something, believe me, when the system is a couple of years old and there are thousands of files in it, then such logging is indispensable for fixing a problem or finding an error. Even sometimes, in the form of a temporary patch, you can correct SQL statements before they are executed.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question