Mysql bin-log Log configuration and recovery data

Source: Internet
Author: User
Tags log log mysql client

1: Before using the log to confirm that the log is open, log in to the MySQL client,
mysql-uroot-p123456
(If the source is installed and the path to the MySQL bin is not added to the environment variable, you can enter
/usr/local/mysql/bin/mysql-uroot-p123456
or a home directory to configure the. bash_profile file to add the/usr/local/mysql/bin to the environment variable once, enter:
Shou variables like "%bin%",
See if the value of Log_bin is on.

2: Configure the Bin-log log if the above Log_bin value is not on, then edit the MySQL configuration file,
VIM/ETC/MY.CNF,
Join under [mysqld] (note not mysqld_safe) module
Log_bin=/usr/local/mysql/log/mysql-bin
(log must be present, the log file begins with Mysql-bin).

3: Restart the MySQL client,
Service mysqld Restart,
At this point you can see two files in the/usr/local/mysql/log directory, respectively
Mysql-bin.000001 and Mysql-bin.index,
mysql-bin.000001 is to record MySQL and delete data records, log in to the MySQL CLI,
Switch to the test database,
Use Test,
Create a table,
CREATE TABLE TLog (
ID Int (TEN) unsigned NOT NULL
) Engine=innodb default Charset=utf8 collate=utf8_general_ci;
Insert a piece of data:
INSERT into TLog values (13);
To refresh the Bin-log log, enter:
Flust logs,
That's when you get a mysql-bin.000002 file under/usr/local/mysql/log.

4: Now the simulation server crashes, the data is lost, to revert to the previous data, in the MySQL CLI input:
Delete from TLog;
Now delete the data and enter it in the shell CLI:
mysqlbinlog/usr/local/mysql/log/mysql-bin.000001 | mysql-uroot-p123456 Test
(Test is a database, because the log is binary, so the general editor such as VI and Vim cannot be viewed, you can use
mysqlbinlog/usr/local/mysql/log/mysql-bin.000001
To view)

Mysql bin-log Log configuration and recovery data

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.