Home  >  Article  >  Database  >  What should I do if mysql fails to set log-bin?

What should I do if mysql fails to set log-bin?

coldplay.xixi
coldplay.xixiOriginal
2020-09-03 13:42:122195browse

The solution to the failure of mysql to set "log-bin": first modify the [my.cnf] file; then store the log file in binary form; finally find the binary file and use the command to export it.

What should I do if mysql fails to set log-bin?

【Related learning recommendations: mysql tutorial(Video)】

Methods to solve mysql failure to set log-bin:

1. Modify the my.cnf file

log-bin=mysql-bin
binlog_do_db=hello
  • log-bin: Setting this parameter means enabling the binlog function and specifying the path name

  • binlog_do_db: Specifying the name of the database for recording logs

After modifying the file, you need to restart the database service

2. The log file exists in binary form. Find the binary file and use the command to export it

a ) Find the binary file storage location

[root@CCDT-gluster-1 mysql]# ps -ef | grep mysql
root     12017     1  0 13:45 pts/0    00:00:00 /bin/sh /usr/bin/mysqld_safe --datadir=/home/Mysql/MysqlData --pid-file=/home/Mysql/MysqlData/mysql1.pid
mysql    12336 12017  0 13:45 pts/0    00:00:02 /usr/sbin/mysqld --basedir=/usr --datadir=/home/Mysql/MysqlData --plugin-dir=/usr/lib64/mysql/plugin --user=mysql --log-error=/home/Mysql/MysqlData/CCDT-gluster-1.err --pid-file=/home/Mysql/MysqlData/mysql1.pid
root     14080 26031  0 13:50 pts/0    00:00:00 grep mysql
root     20668     1  0 May11 ?        00:00:00 mysql -u root -p

b) The binary file is stored in the directory where the database file is located, use the mysqlbinlog command to export

[root@CCDT-gluster-1 mysql]# cd /home/Mysql/MysqlData
[root@CCDT-gluster-1 MysqlData]# mysqlbinlog --start-datetime='2016-11-17 12:00:00' --stop-datetime='2016-11-17 17:00:00' mysql-bin.000001 > ./hello.txt

If you want to learn more about programming, please stay tuned. php training column!

The above is the detailed content of What should I do if mysql fails to set log-bin?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn