2016-10-27 24 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

相关问题