MySQL 5.6.26
MySQL 5.6.26
Trying to log queries to stdout doesn't work below,
尝试将查询记录到stdout在下面不起作用,
$ mysqld --general_log=1 --general_log_file=/dev/stdout
1 个解决方案
#1
2
You can't, not directly. The query logs only go to files, tables or nowhere. They don't seem to go to /dev/stdout
nor honor the -
convention. Don't worry, there's a much better way.
你不能,不能直接。查询日志只会转到文件,表或任何地方。他们似乎没有去/ dev / stdout,也没有遵守 - 惯例。别担心,有一个更好的方法。
If all you want to do is see the query log as it happens, you can stream the log file using various Unix utilities. tail -f
is one option.
如果您只想查看查询日志,则可以使用各种Unix实用程序来传输日志文件。 tail -f是一种选择。
tail -f /path/to/query.log
I prefer opening the log with less
and using the F
command to keep reading as the file is added to. It's like tail -f
but you can also scroll around and search the file.
我更喜欢用less打开日志,并使用F命令在添加文件时继续读取。它就像tail -f但你也可以滚动并搜索文件。
$ less /path/to/query.log
~
~
/opt/local/lib/mysql56/bin/mysqld, Version: 5.6.27-log (Source distribution). started with:
Tcp port: 0 Unix socket: (null)
Time Id Command Argument
151004 16:10:51 1 Connect schwern@localhost as on
1 Query select @@version_comment limit 1
151004 16:10:53 1 Query select 1
151004 16:10:54 1 Quit
Waiting for data... (interrupt to abort)
#1
2
You can't, not directly. The query logs only go to files, tables or nowhere. They don't seem to go to /dev/stdout
nor honor the -
convention. Don't worry, there's a much better way.
你不能,不能直接。查询日志只会转到文件,表或任何地方。他们似乎没有去/ dev / stdout,也没有遵守 - 惯例。别担心,有一个更好的方法。
If all you want to do is see the query log as it happens, you can stream the log file using various Unix utilities. tail -f
is one option.
如果您只想查看查询日志,则可以使用各种Unix实用程序来传输日志文件。 tail -f是一种选择。
tail -f /path/to/query.log
I prefer opening the log with less
and using the F
command to keep reading as the file is added to. It's like tail -f
but you can also scroll around and search the file.
我更喜欢用less打开日志,并使用F命令在添加文件时继续读取。它就像tail -f但你也可以滚动并搜索文件。
$ less /path/to/query.log
~
~
/opt/local/lib/mysql56/bin/mysqld, Version: 5.6.27-log (Source distribution). started with:
Tcp port: 0 Unix socket: (null)
Time Id Command Argument
151004 16:10:51 1 Connect schwern@localhost as on
1 Query select @@version_comment limit 1
151004 16:10:53 1 Query select 1
151004 16:10:54 1 Quit
Waiting for data... (interrupt to abort)