-bash:mysqlbinlog:command not found
First you need to know the full path to the MySQL command or mysqldump command, and you can use the Find command to find
Find/-name Mysql-print
My MySQL path is:/usr/local/mysql/bin/mysql, then map a link to the/usr/bin directory, equivalent to creating a linked file
Ln-fs/usr/local/mysql/bin/mysql/usr/bin
Similarly: Ln-s/usr/local/mysql/bin/mysqlbinlog/usr/bin
Before 5.7:
Modify the my.cnf file, add Log-bin=my-bin (my.cnf location according to the path of your own installation view)
# VI/USR/LOCAL/MYSQL/MY.CNF
Log-bin=my-bin #my-bin is the name of the Bin-log file, and you can customize the file name according to your own situation
or customize the location where the bin-log is stored, by default in the MySQL data directory, such as
Log-bin=/mysql/data/my-bin
Note: The permissions for the/mysql/data folder require MySQL.
The default is to have mysql-bin.00001 under/mysql/data/...
Need to restart MySQL after modification
# service MySQL Restart
Viewmysql-bin.00001Log file:
Mysqlbinlog mysql0bin.00001 |less
Like what:
‘/*!*/;
# at 120
#180412 8:53:44 Server ID 1 end_log_pos 203 CRC32 0xb1a0533f Query thread_id=5153988 exec_time=0
Error_code=0
SET timestamp=1523494424/*!*/;
SET @ @session. pseudo_thread_id=5153988/*!*/;
SET @ @session. Foreign_key_checks=1, @ @session. sql_auto_is_null=0, @ @session. Unique_checks=1, @ @session. autocommit= 1/*!*/;
SET @ @session. sql_mode=1075838976/*!*/;
SET @ @session. auto_increment_increment=1, @ @session. auto_increment_offset=1/*!*/;
/*!\c UTF8 *//*!*/;
SET @ @session. character_set_client=33,@ @session. collation_connection=33,@ @session. collation_server=45/*!*/;
SET @ @session. lc_time_names=0/*!*/;
SET @ @session. collation_database=default/*!*/;
BEGIN
/*!*/;
# at 203
#180412 8:53:44 Server ID 1 end_log_pos 703 CRC32 0x04607463 Query thread_id=5153988 exec_time=0
Error_code=0
Use ' Zabbix '/*!*/;
SET timestamp=1523494424/*!*/;
Insert into history (Itemid,clock,ns,value) values (24103,1523494423,873193168,2.450000), ( 24283,1523494423,995677732,4.266667), (24163,1523494423,998621650,0.000000), (24523,1523494424,3255086,0.000000) , (24164,1523494424,5611211,0.004164), (24104,1523494424,12912322,0.000000), (24344,1523494424,14527510,0.058611) , (25064,1523494424,16363257,0.050000), (24284,1523494424,19002870,0.000000), ( 24524,1523494424,76535760,95.865357)
Can find location, time, etc. through at
If you delete a database library or a table, you can recover the document with mysql-bin.000012.
View with Mysqlbinlog tool
Based on start/end time
mysqlbinlog--start-datetime= ' 2016-08-02 00:00:00 '--stop-datetime= ' 2016-08-03 23:01:01 '-D hadoop/data/mysql/ data/mysql-bin.000001
Based on POS value, note: Hadoop is a library name,/var/lib/mysql/mysql-bin.000001 is a binary file path
mysqlbinlog--start-position=2098--stop-position=2205-d hadoop/data/mysql/data/mysql-bin.000001
Mysqlbinlog Backup and mysqldump backup