Jimmy_Wang: MySQL opens log_bin log, your last straw when you delete the database by mistake

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
  1. Log in directly with the mysql -u root -p command
  2. Use show variables like'log_%'; verify that binlog is turned on
    Insert picture description here

Obviously based on the above picture, our log_bin is obviously in an unopened state

  1. Find the location of the mysql configuration file my.cnf
    Insert picture description here

  2. Use vim editor to edit the specified path file
    Insert picture description here

  3. Insert the following code in my.cnf, save and exit
    Insert picture description here

  4. Restart mysql
    Insert picture description here

  5. View log-bin open
    Insert picture description here

  6. Confirm the log-bin data storage address, the following two files appear, indicating that log-bin has been opened successfully
    Insert picture description here

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.

Guess you like

Origin blog.csdn.net/qq_41475067/article/details/112486597