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

Processing method of erroneous deletion of mysql

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

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

Check whether the binary log function is enabled: show variables like'% bin%';. If log-bin shows that off is not open, then add log-bin=mysql-bin under [mysqld] in / etc/my.cnf (where mysql-bin is the beginning name of the log file and can be customized).

Mysql mistakenly deleted data files

The first method: this method requires that the binary file is very complete. If there is no table statement in the binary file, you will not be able to recover the table in drop.

Check which binary is being used: show master status; sees mysql-bin.000002

Backup: mysqlbinlog mysql-bin.000002 > test1.sql

Modify sensitive data: for example, drop database xx

Restore: mysql < test1.sql

The second method:

The first step is to see what the name of the binary log file currently in use is: show master status

Check how many binary log files are currently available and their size: show master logs

Second: the command to look at the log file, mainly depends on what sql statements are in the log file, and find out the time point to perform the following recovery operation: / usr/local/mysql/bin/mysqlbinlog mysql-bin.000091 | less

There are two ways to recover from binary log files: one is by time: / usr/local/mysql/bin/mysqlbinlog-- start-datetime '2017-02-140 stop-datetime' 2017-02-140 stop-datetime 12 stop-datetime 59'- 14 013 stop-datetime 31' mysql-bin.000091 | mysql- uroot-time depends on the time

The start time of create table c2 in the image above is 2017-02-14 0:12:59 and the stop time is 2017-02-14 0:13:31

The at xxx,xxx in the second image above is the size. Look at the size: / usr/local/mysql/bin/mysqlbinlog-- start-position=361-- stop-position=574 mysql-bin.000091 | mysql- uroot-proot

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