Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Service Log and backup Command of mysql

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Mysqlbinlog:

Used to parse binlog logs. Under the data directory, mysql.index is the index file for mysqlbinlog. The function of binlog is to record the additions, deletions and changes within mysql. No record of select.

Options:

1. Murd dbname: used to disassemble the library and separate the binary log of the specified library.

2. Mustang mysqldump mysql-bin.000006-- start-position=486-- stop-position=1156 > test.sql

Master-data=

When it is 2, the line master_log_pos is commented out, and when it is 1, the line master_log_pos is uncommented.

Equal to the role of 1, when synchronizing as a master and slave, use the line-- master-data=1,master_log_pos without comments, and pour the whole slave into the slave library, master_log_pos will tell you where to start the recovery from the master library.

Log files in the mysql database

Error log (error log): log errors encountered during startup and shutdown or running of the mysql service process mysqld

Query log:

General query log (query log): records client connection information and executes sql statement information

Slow query log (slow query log): record sql statements that take longer than the specified value or execute sql statements without indexes (optimizing slow query sql statements is what DBA does)

Binary log (binary log): records information about the modification of data:

Error log: ending in err in the data data directory

Binary log: bin-log

Ordinary query log and slow query log are generally not opened, and the log file is too large.

For normal logs:

Mysql > show variables like'% log%'

Open it using set:

Mysql > set global general_log = ON;Query OK, 0 rows affected (0.01 sec)

Then randomly create or query a few tables, which will be recorded in the localhost.log file.

Slow query: (configured in / etc/my.cnf)

# sql statements with query time longer than 1 second will be recorded

Long_query_time=1

# record queries that do not use indexes

Log_queries_not_using_indexes=1

# record the file address of the slow query log

Slow-query-log-file=/usr/local/mysql/localhost-slow.log

There are three modes for binlog logs.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report