For secondary development, a large part is looking for files and database changes.
For database changes. Have not found a relatively easy to use monitoring database change monitoring software.
Today, I will show you how to use the function that comes with mysql to monitor database changes
1. Open the database configuration file my.ini (usually in the database installation directory) (D:\MYSQL) 2. Add log=
to the last line of the database
log.txt
code
3. Restart the mysql database
4. Go to the database data directory, mine is (D:\MYSQL\data) You will find an additional log.txt file.
Mine is in C:\Documents and Settings\All Users\ Application Data\MySQL\MySQL Server 5.5\data
test:
1. Operate on the database
2. Check the content of the log.txt file. If you find any changes, you can monitor the changes in the mysql database. You can check the
database query, delete, update and insert.
Hope This article can help you develop faster ^_^
log file types overview:
1.
Error log Records problems starting, running, or stopping mysqld.
My.ini configuration information:
#Enter a name for the error log file. Otherwise a default name will be used.
#log-error=d:/mysql_log_err.txt
2.
Query Log Records client connections established and statements executed.
My.ini configuration information:
#Enter a name for the query log file. Otherwise a default name will be used.
#log=d:/mysql_log.txt
3.
Changelog Records statements that change data. This log is deprecated.
My.ini configuration information:
#Enter a name for the update log file. Otherwise a default name will be used.
#log-update=d:/mysql_log_update.txt
4.
The binary log records all statements that change data. Also used for replication.
My.ini configuration information:
#Enter a name for the binary log. Otherwise a default name will be used.
#log-bin=d:/mysql_log_bin
5.
Slow log Logs all queries that take longer than long_query_time seconds to execute or queries that do not use indexes.
My.ini configuration information:
#Enter a name for the slow query log file. Otherwise a default name will be used.
#long_query_time =1
#log-slow-queries= d:/mysql_log_slow.txt
在linux下:
Sql代码
1. # 在[mysqld] 中输入
2. #log
3. log-error=/usr/local/mysql/log/error.log
4. log=/usr/local/mysql/log/mysql.log
5. long_query_time=2
6. log-slow-queries= /usr/local/mysql/log/slowquery.log
# 在[mysqld] 中输入 #log log-error=/usr/local/mysql/log/error.log log=/usr/local/mysql/log/mysql.log long_query_time=2 log-slow-queries= /usr/local/mysql/log/slowquery.log
windows下:
Sql代码
1. # 在[mysqld] 中输入
2. #log
3. log-error="E:/PROGRA~1/EASYPH~1.0B1/mysql/logs/error.log"
4. log="E:/PROGRA~1/EASYPH~1.0B1/mysql/logs/mysql. log"
5. long_query_time=2
6. log-slow-queries= "E:/PROGRA~1/EASYPH~1.0B1/mysql/logs/slowquery.log"
# Enter #log log-error=" in [mysqld] E:/PROGRA~1/EASYPH~1.0B1/mysql/logs/error.log" log="E:/PROGRA~1/EASYPH~1.0B1/mysql/logs/mysql.log" long_query_time=2 log-slow- queries= "E:/PROGRA~1/EASYPH~1.0B1/mysql/logs/slowquery.log"
Enable slow query
long_query_time =2 -- means that the sql that has been executed for more than a long time will be logged, here is 2 seconds
log-slow -queries= /usr/local/mysql/log/slowquery.log --return queries to slower statements for logging
log-queries-not-using-indexes = nouseindex.log --literally, no indexes are used in the log query
log=mylog.log -- log all executed statements
Log storage: By default, when enabled, all logs are stored in the DataDir directory. If no name is specified, it will be named after the host name. If the host name is songcomputer, the relevant log is songcomputer. log file.
Reference:
http://www.cnblogs.com/interdrp/p/3443069.html
Real-time monitoring of MySQL database changes
Guess you like
Origin http://43.154.161.224:23101/article/api/json?id=326436152&siteId=291194637
Recommended
Ranking