2016-10-27 27 views
2

我發出了一個查詢,並在mysql>命令行得到了結果。如何查看mysql中發出的最後一條命令?

有什麼方法(除了編輯),我可以看到最後一個查詢是什麼?

我依稀記得,在甲骨文的PL/SQL,你可以只輸入list但命令不可用(語法錯誤)在MySQL

+0

不知道我是否會陳述顯而易見:按「光標上移」?如果這不是你想要的:你有管理員權限/訪問數據庫嗎? – Solarflare

回答

0
Additionally, for those blessed with MySQL >= 5.1.12: 

Execute SET GLOBAL log_output = 'TABLE'; 
Execute SET GLOBAL general_log = 'ON'; 
Take a look at the table mysql.general_log 
If you prefer to output to a file: 

SET GLOBAL log_output = "FILE"; which is set by default. 
SET GLOBAL general_log_file = "/path/to/your/logfile.log"; 
SET GLOBAL general_log = 'ON'; 
I prefer this method because: 

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 
restarting the server leaves you where you started (log is off) 
For more information, see 

http://dev.mysql.com/doc/refman/5.7/en/server-system-variables.html#sysvar_general_log

相關問題