Foreword: Today, a student who has graduated for more than a year came back to me for dinner. When he talked about his own SB thing in the company , he deleted the company database by mistake. Fortunately, the company MySQL opened the log_bin log, so it did not appear. Irreparable loss.
Personal sentiment: Whether it is the "Ape Friends" who has just entered the industry or the "Old Apes" who has been in the industry for a long time, I believe that they will have encountered operations for various reasons (in many cases I deleted the database by mistake). And deleting the database of an online project by mistake is a very scary thing, so what if you encounter this situation? First of all, don't worry (I feel like saying -, -, it seems impossible not to worry). First, take a look at whether your mysql has the log-bin log function enabled, if not? ? ? There is no habit of backing up data regularly, so game over!!!
Then we will talk about how to enable the log_bin log in MySQL
- Log in directly with the mysql -u root -p command
- Use show variables like'log_%'; verify that binlog is turned on
Obviously based on the above picture, our log_bin is obviously in an unopened state
-
Find the location of the mysql configuration file my.cnf
-
Use vim editor to edit the specified path file
-
Insert the following code in my.cnf, save and exit
-
Restart mysql
-
View log-bin open
-
Confirm the log-bin data storage address, the following two files appear, indicating that log-bin has been opened successfully
Special statement: I am an ordinary IT practitioner. Compared with many technical experts, I feel that I am just a junior high school student. Writing this blog post is just to popularize some IT common sense technology. If it really helps you, please Follow and like in time.