2014/07/31

查看 MySQL 的存取記錄 (View MySQL access log on MySQL Server)


[ Quick Solution Mode ]
$ sudo vi /etc/mysql/my.cnf
# unmark the following lines: (your could search "mysql.log")
general_log_file        = /var/log/mysql/mysql.log
general_log             = 1

$ sudo service mysql restart
# Now you could view all the MySQL access log
$ cat /var/log/mysql/mysql.log         # view whole file
# OR
$ tail -f /var/log/mysql/mysql.log     # view file output appended data as the file grows

[ Verbose Mode ]
不論是為了什麼原因使用資料庫,
總是有可能希望知道網頁對資料庫下了什麼語法,
或想知道資料庫的查詢,存取記錄,

使用 MySQL 做為資料庫時,
預設是沒有開啟 "存取記錄" 這項功能的,
需要手動開啟,
步驟和作法如上述,
記得修改後要重新啟動 mysql

[ Environment ]
$ mysql --version
mysql  Ver 14.14 Distrib 5.5.35, for debian-linux-gnu (x86_64) using readline 6.3



[ Reference ]
Tsung 還有提供其他方法, 可以參考看看~ http://blog.longwin.com.tw/2007/06/mysql_record_any_sql_command_2007/

沒有留言:

張貼留言