做微网站用什么框架/网络营销自学网站
1. 查看 binlog 是否开启
show global variables like 'log_bin';
sql_log_bin : 当前会话 是否要记录 binlog
2. mysql 添加如下配置
修改 my.cnf 文件,一般来说都位于 /etc/my.cnf 这边。
在 [mysqld] 下写入如下内容:
## binlog d的日志模式
binlog-format=ROW
## 开启 bin log 生成binlog 日志的基础名称
log-bin=mysqlbinlog
## 集群环境下 需要设置一个不重复的id
server-id=1
3 . 重启服务
service mysql restart
或者
systemctl restart mysqld
4. 查看binlog 的日志信息
show binary logs;
5. 查看当前正在写入的binlog 信息
show master status;
6. 查看binlog 的事件
不指定名称默认就是查看的是 mysqlbinlog.000001的信息
show binlog events;
也可以指定文件名
show binlog events in 'mysqlbinlog.000001';
也可以通过mysqlbinlog 工具进行查看
7. 输出指定的binlog 日志
mysqlbinlog --start-position='4' --stop-position='100';
也可以输出到某个文件中
mysqlbinlog --start-position='4' --stop-position='100' mysqlbinlog.000001 >1.log;
也可以压缩
mysqlbinlog --start-position='4' --stop-position='100' mysqlbinlog.000001|gzip >1.gzip;
也可以通过时间查看binlog
mysqlbinlog --start-datetime='2023-3-24 21:32:32' mysqlbinlog.000001;
D:\devtools\MariaDB 10.5\bin>mariadb-binlog.exe
mariadb-binlog.exe Ver 3.4 for Win64 at AMD64
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.Dumps a MariaDB binary log in a format usable for viewing or for piping to
the mysql command line client.Usage: mariadb-binlog.exe [options] log-filesDefault options are read from the following files in the given order:
C:\WINDOWS\my.ini C:\WINDOWS\my.cnf C:\my.ini C:\my.cnf D:\devtools\MariaDB 10.5\my.ini D:\devtools\MariaDB 10.5\my.cnf D:\devtools\MariaDB 10.5\data\my.ini D:\devtools\MariaDB 10.5\data\my.cnf
The following groups are read: mysqlbinlog mariadb-binlog client client-server client-mariadb
The following options may be given as the first argument:
--print-defaults Print the program argument list and exit.
--no-defaults Don't read default options from any option file.
The following specify which files/extra groups are read (specified before remaining options):
--defaults-file=# Only read default options from the given file #.
--defaults-extra-file=# Read this file after the global files are read.
--defaults-group-suffix=# Additionally read default groups with # appended as a suffix.-?, --help Display this help and exit.--base64-output[=name]Determine when the output statements should bebase64-encoded BINLOG statements: 'never' doesn't printbinlog row events and should not be used when directingoutput to a MariaDB master; 'decode-rows' decodes rowevents into commented SQL statements if the --verboseoption is also given; 'auto' prints base64 only whennecessary (i.e., for row-based events and formatdescription events); 'always' prints base64 wheneverpossible. --base64-output with no 'name' argument isequivalent to --base64-output=always and is alsodeprecated. If no --base64-output[=name] option is givenat all, the default is 'auto'.--character-sets-dir=nameDirectory for character set files.-d, --database=name List entries for just this database (local log only).--debug-check Check memory and open file usage at exit .--debug-info Print some debug info at exit.--default-auth=name Default authentication client-side plugin to use.-D, --disable-log-binDisable binary log. This is useful, if you enabled--to-last-log and are sending the output to the sameMariaDB server. This way you could avoid an endless loop.You would also like to use it when restoring after acrash to avoid duplication of the statements you alreadyhave. NOTE: you will need a SUPER privilege to use thisoption.-B, --flashback Flashback feature can rollback you committed data to aspecial time point.-F, --force-if-open Force if binlog was not closed properly.(Defaults to on; use --skip-force-if-open to disable.)-f, --force-read Force reading unknown binlog events.-H, --hexdump Augment output with hexadecimal and ASCII event dump.-h, --host=name Get the binlog from server.-l, --local-load=namePrepare local temporary files for LOAD DATA INFILE in thespecified directory.-o, --offset=# Skip the first N entries.-p, --password[=name]Password to connect to remote server.--plugin-dir=name Directory for client-side plugins.-P, --port=# Port number to use for connection or 0 for default to, inorder of preference, my.cnf, $MYSQL_TCP_PORT,/etc/services, built-in default (3306).--protocol=name The protocol to use for connection (tcp, socket, pipe).-R, --read-from-remote-serverRead binary logs from a MariaDB server.--raw Requires -R. Output raw binlog data instead of SQLstatements. Output files named after server logs.-r, --result-file=nameDirect output to a given file. With --raw this is aprefix for the file names.--print-row-count Print row counts for each row events(Defaults to on; use --skip-print-row-count to disable.)--print-row-event-positionsPrint row event positions(Defaults to on; use --skip-print-row-event-positions to disable.)--server-id=# Extract only binlog entries created by the server havingthe given id.--set-charset=name Add 'SET NAMES character_set' to the output.-s, --short-form Just show regular queries: no extra info, no row-basedevents and no row counts. This is mainly for testingonly, and should not be used to feed to the MariaDBserver. If you want to just suppress base64-output, youcan instead use --base64-output=never-S, --socket=name The socket file to use for connection.--ssl Enable SSL for connection (automatically enabled withother flags).--ssl-ca=name CA file in PEM format (check OpenSSL docs, implies--ssl).--ssl-capath=name CA directory (check OpenSSL docs, implies --ssl).--ssl-cert=name X509 cert in PEM format (implies --ssl).--ssl-cipher=name SSL cipher to use (implies --ssl).--ssl-key=name X509 key in PEM format (implies --ssl).--ssl-crl=name Certificate revocation list (implies --ssl).--ssl-crlpath=name Certificate revocation list path (implies --ssl).--tls-version=name TLS protocol version for secure connection.--ssl-verify-server-certVerify server's "Common Name" in its cert againsthostname used when connecting. This option is disabled bydefault.--start-datetime=nameStart reading the binlog at first event having a datetimeequal or posterior to the argument; the argument must bea date and time in the local time zone, in any formataccepted by the MariaDB server for DATETIME and TIMESTAMPtypes, for example: 2004-12-25 11:25:56 (you shouldprobably use quotes for your shell to set it properly).-j, --start-position=#Start reading the binlog at position N. Applies to thefirst binlog passed on the command line.--stop-datetime=nameStop reading the binlog at first event having a datetimeequal or posterior to the argument; the argument must bea date and time in the local time zone, in any formataccepted by the MariaDB server for DATETIME and TIMESTAMPtypes, for example: 2004-12-25 11:25:56 (you shouldprobably use quotes for your shell to set it properly).--stop-never Wait for more data from the server instead of stopping atthe end of the last log. Implies --to-last-log.--stop-never-slave-server-id=#The slave server_id used for --read-from-remote-server--stop-never.--stop-position=# Stop reading the binlog at position N. Applies to thelast binlog passed on the command line.-T, --table=name List entries for just this table (local log only).-t, --to-last-log Requires -R. Will not stop at the end of the requestedbinlog but rather continue printing until the end of thelast binlog of the MariaDB server. If you send the outputto the same MariaDB server, that may lead to an endlessloop.-u, --user=name Connect to the remote server as username.-v, --verbose Reconstruct SQL statements out of row events. -v -v addscomments on column data types.-V, --version Print version and exit.--open-files-limit=#Used to reserve file descriptors for use by this program.--binlog-row-event-max-size=#The maximum size of a row-based binary log event inbytes. Rows will be grouped into events smaller than thissize if possible. This value must be a multiple of 256.-c, --verify-binlog-checksumVerify checksum binlog events.--rewrite-db=name Updates to a database with a different name than theoriginal. Example: rewrite-db='from->to'.--skip-annotate-row-eventsDon't print Annotate_rows events stored in the binarylog.--print-table-metadataPrint metadata stored in Table_map_log_eventVariables (--variable-name=value)
and boolean options {FALSE|TRUE} Value (after reading options)
--------------------------------- ----------------------------------------
base64-output (No default value)
character-sets-dir (No default value)
database (No default value)
debug-check FALSE
debug-info FALSE
default-auth (No default value)
disable-log-bin FALSE
flashback FALSE
force-if-open TRUE
force-read FALSE
hexdump FALSE
host (No default value)
local-load (No default value)
offset 0
plugin-dir D:/devtools/MariaDB 10.5/lib/plugin
port 3306
read-from-remote-server FALSE
raw FALSE
result-file (No default value)
print-row-count TRUE
print-row-event-positions TRUE
server-id 0
set-charset (No default value)
short-form FALSE
socket (No default value)
ssl FALSE
ssl-ca (No default value)
ssl-capath (No default value)
ssl-cert (No default value)
ssl-cipher (No default value)
ssl-key (No default value)
ssl-crl (No default value)
ssl-crlpath (No default value)
tls-version (No default value)
ssl-verify-server-cert FALSE
start-datetime (No default value)
start-position 4
stop-datetime (No default value)
stop-never FALSE
stop-never-slave-server-id 0
stop-position 18446744073709551615
table (No default value)
to-last-log FALSE
user (No default value)
open-files-limit 18432
binlog-row-event-max-size 4294967040
verify-binlog-checksum FALSE
skip-annotate-row-events FALSE
print-table-metadata FALSE