如何查看mysql中发出的最后一个命令?
我在如何查看mysql中发出的最后一个命令?,mysql,sql,Mysql,Sql,我在mysql>命令行发出了一个查询并得到了结果 是否有任何方法(编辑除外)可以查看上一个查询是什么 我模模糊糊地记得,在oraclepl/sql中,您可以只键入list,但该命令在mysql中不可用(语法错误) 我不确定是否会说出明显的问题:按“光标向上”键?如果这不是您想要的:您是否拥有数据库的管理员权限/访问权限? Additionally, for those blessed with MySQL >= 5.1.12: Execute SET GLOBAL log_output
mysql>
命令行发出了一个查询并得到了结果
是否有任何方法(编辑除外)可以查看上一个查询是什么
我模模糊糊地记得,在oraclepl/sql中,您可以只键入list
,但该命令在mysql中不可用(语法错误)
我不确定是否会说出明显的问题:按“光标向上”键?如果这不是您想要的:您是否拥有数据库的管理员权限/访问权限?
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