4

有没有办法从 mysql 控制台知道 bin 日志文件路径,因为我们可以通过使用知道它是 ON 还是 OFF

Select * information_schema.GLOBAL_VARIABLES
where variable_name like '%log_bin%'. 
4

2 回答 2

5

使用它来显示开/关

SHOW VARIABLES LIKE 'log_bin'

还:

SHOW GLOBAL VARIABLES LIKE '%bin%'

或者

SHOW SESSION VARIABLES LIKE ...

更多信息:(请注意,其中一些值和结果从 5.5 更改为 5.6!)

http://dev.mysql.com/doc/refman/5.5/en/show-master-status.html

mysql > SHOW MASTER STATUS;
+---------------+----------+--------------+------------------+
| File          | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+---------------+----------+--------------+------------------+
| mysql-bin.003 | 73       | test         | manual,mysql     |
+---------------+----------+--------------+------------------+

mysql> SHOW BINARY LOGS;
+---------------+-----------+
| Log_name      | File_size |
+---------------+-----------+
| binlog.000015 |    724935 |
| binlog.000016 |    733481 |
+---------------+-----------+
于 2013-12-04T10:00:37.660 回答
1

有关log-bin“ _

Setting this option causes the log_bin system variable to be set 
to ON (or 1), and not to the base name. This is a known issue; 
see Bug #19614 for more information.

在我修改了一下mysqldBug 19614中有一个解决方法。如果您正在编写脚本,则可以从mysql客户端使用(我发现这样做有点乏味,请参阅下一个解决方法):

mysql >\! dirname $(mysqld --help --verbose 2> /dev/null | egrep "^log-bin " | grep -o "\/.*")

看起来有一个由 Mark Callaghan 提交的补丁,但从未提交过。WP5465中有一个功能(这是此补丁正在进行的工作),但是它对我来说不能正常工作,因为日志的位置可能因设置而异。

于 2016-05-23T17:53:52.720 回答