show variables like 'log_bin%';
打开二进制日志:
vi /etc/my.cnf --添加:
log_bin=/data/mysql/binlogs/s1
server_id=10
显示服务器的所有二进制日志
show master logs;
show binary logs;
执行命令show master status; 以获取当前的二进制日志位置。
set sql_log_bin=0;
在这条语句执行后的所有sql语句都不会记录到二进制日志中,只针对该session
要重启启动二进制日志,可以执行以下操作:
set sql_lob_bin=1;
可以使用flush logs命令关闭当前的二进制日志 并打开一个新的二进制而知:
show binary logs;
flush logs;
show binary logs;
清理二进制日志:
使用binlog_expire_logs_seconds(秒为单位) 和 expire_logs_days (天为单位)设置日志的到期时间。
设置的清理时间是binlog_expire_logs_seconds+expire_logs_days的时间。
手动清除二进制日志:
purge binary logs to '<file_name>'
purge binary logs to 's1.000002'; 只会清除2以前的。
删除所有的二进制日志,从头开始:
show master logs;
reset master;
show master logs;
二进制日志的格式:
-
STATEMENT
causes logging to be statement based. -
ROW
causes logging to be row based. -
MIXED
causes logging to use mixed format.
mysql> show variables like 'binlog_format';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| binlog_format | ROW |
+---------------+-------+
1 row in set (0.00 sec)
The logging format also can be switched at runtime, although note that there are a number of situations in which you cannot do this, as discussed later in this section.
Set the global value of the binlog_format system variable to specify the format for clients that connect subsequent to the change:
mysql> SET GLOBAL binlog_format = 'STATEMENT';
mysql> SET GLOBAL binlog_format = 'ROW';
mysql> SET GLOBAL binlog_format = 'MIXED';
flush logs;
重新登录。
quit
mysql -uroot -p
查看全局的时候,show 加上GLOBAL
==================隔离级别===================
The isolation level is used for operations on InnoDB tables.
SELECT @@GLOBAL.transaction_isolation, @@GLOBAL.transaction_read_only;
SELECT @@SESSION.transaction_isolation, @@SESSION.transaction_read_only;
SET [GLOBAL | SESSION] TRANSACTION
transaction_characteristic [, transaction_characteristic] ...
transaction_characteristic: {
ISOLATION LEVEL level
| access_mode
}
level: {
REPEATABLE READ
| READ COMMITTED
| READ UNCOMMITTED
| SERIALIZABLE
}
access_mode: {
READ WRITE
| READ ONLY
}
SET global TRANSACTION ISOLATION LEVEL SERIALIZABLE;