本文介紹了如何顯示在 MySQL 上執(zhí)行的最后查詢?的處理方法,對大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!
問題描述
是否有任何查詢/方法可以顯示在所有服務(wù)器上執(zhí)行的最后查詢?
Is there any query/way to show the last queries executed on ALL servers?
推薦答案
對于那些擁有 MySQL >= 5.1.12 的人,你可以在運(yùn)行時(shí)全局控制這個(gè)選項(xiàng):
For those blessed with MySQL >= 5.1.12, you can control this option globally at runtime:
- 執(zhí)行
SET GLOBAL log_output = 'TABLE';
- 執(zhí)行
SET GLOBAL general_log = 'ON';
- 看一下表
mysql.general_log
如果您更喜歡輸出到文件而不是表格:
If you prefer to output to a file instead of a table:
SET GLOBAL log_output = "FILE";
默認(rèn).SET GLOBAL general_log_file = "/path/to/your/logfile.log";
SET GLOBAL general_log = 'ON';
我更喜歡這種方法來編輯 .cnf 文件,因?yàn)?
I prefer this method to editing .cnf files because:
- 您沒有編輯
my.cnf
文件并可能永久開啟日志記錄 - 您不是在文件系統(tǒng)中四處尋找查詢?nèi)罩尽蛘吒愕氖牵驗(yàn)樾枰昝赖哪康牡囟中?
/var/log/var/data/log
/opt/home/mysql_savior/var
- 您不必重新啟動(dòng)服務(wù)器并中斷與它的任何當(dāng)前連接.
- 重新啟動(dòng)服務(wù)器會(huì)使您從開始的地方離開(默認(rèn)情況下日志仍處于關(guān)閉狀態(tài))
- you're not editing the
my.cnf
file and potentially permanently turning on logging - you're not fishing around the filesystem looking for the query log - or even worse, distracted by the need for the perfect destination.
/var/log /var/data/log
/opt /home/mysql_savior/var
- You don't have to restart the server and interrupt any current connections to it.
- restarting the server leaves you where you started (log is by default still off)
有關(guān)更多信息,請參閱MySQL 5.1 參考手冊 - 服務(wù)器系統(tǒng)變量 - general_log
這篇關(guān)于如何顯示在 MySQL 上執(zhí)行的最后查詢?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!
【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!