Causes and solutions for MySQL data loss

Causes and solutions for MySQL data loss

Preface

Recently, we occasionally receive feedback from users about missing data or data loss. From a phenotypic perspective, this type of problem is the most urgent one at the database level. Putting aside objective conditions, the only recovery methods for this type of problem are backup recovery + Binlog playback, which usually takes a long time and has a great impact on the business.

However, as a software that focuses on stability, the probability of data loss is actually very low, so are these feedback issues really about "data loss"?

Problem Description

One day at noon, we received feedback from a user that after logging into the database with a business account, the business database disappeared.

Cause Analysis

When I received this question, the atmosphere was still very tense. On the one hand, I contacted the user to authorize login to the database for investigation, and on the other hand, I was communicating with the user to see what changes had been made recently.

After logging in to the database, I found that the business database existed. Combined with the user's feedback: "The business database is gone", I initially determined that the business account did not have permissions. After checking with show grants, I found that the business account only had USAGE permissions, similar to the following effect:

mysql> show grants;
+----------------------------------+
| Grants for test@% |
+----------------------------------+
| GRANT USAGE ON *.* TO 'test'@'%' |
+----------------------------------+
1 row in set (0.00 sec)

Since this account only has the minimum permissions, it is obvious that it “cannot see business data”, so after re-authorization, the problem was solved. After investigation, it was found that the initial authorization operation occurred on another account with the same name, similar to:

mysql> show grants;
+-------------------------------------------------------------+
| Grants for [email protected].% |
+-------------------------------------------------------------+
| GRANT ALL PRIVILEGES ON prd_name.* TO 'test'@'10.120.117.%' |
+-------------------------------------------------------------+
1 row in set (0.00 sec)

mysql>

Expand

Regarding the phenomenon of "data loss", if the data at the entire database level is "lost", but the database itself is normal, there is a high possibility that the problem is the same as in this case: permission error. There are generally two possibilities that may cause this problem: 1. The logged-in account matches another account with the same name; 2. There is a problem with authorization, resulting in the business account having no permissions. Of course, the worst case is definitely the drop database operation. Only by parsing the binlog can the time of executing this operation be located.

The other category is "partial data loss", such as a table is missing, or some data in the table is missing, etc. Strictly speaking, this type of problem may also be caused by permission errors, because MySQL's permission control can indeed be done at the table and column level, but it is generally not used in reality. Most of the time it is due to an incorrect operation, such as not having a where condition when updating or deleting. In this case, you can only use historical backup and then restore using binlog. This operation is encapsulated as a "rollback" function on Tencent Cloud.

To sum up

When you encounter this type of problem, you can take a moment to observe the problem. It may only take a few seconds to reauthorize to solve this very urgent and serious "data loss" problem.

The above are the detailed reasons and solutions for MySQL data loss. For more information about MySQL data loss, please pay attention to other related articles on 123WORDPRESS.COM!

You may also be interested in:
  • Solve the problem of mysql data loss when docker restarts redis
  • Solution to the problem of data loss when using Replace operation in MySQL
  • Several solutions to prevent MySQL data loss when the server goes down
  • MySQL data loss troubleshooting case

<<:  Summary of Spring Boot Docker packaging tools

>>:  Vue+axios sample code for uploading pictures and recognizing faces

Recommend

Detailed explanation of the platform bus of Linux driver

Table of contents 1. Introduction to platform bus...

Detailed steps to install JDK and Tomcat in Linux environment

Table of contents 1. Install JDK Manual Installat...

Issues with Rancher deployment and importing K8S clusters

Rancher deployment can have three architectures: ...

Running PostgreSQL in Docker and recommending several connection tools

1 Introduction PostgreSQL is a free software obje...

How to install MySQL 8.0 in Docker

Environment: MacOS_Cetalina_10.15.1, Mysql8.0.18,...

Detailed introduction to the MySQL installation tutorial under Windows

Table of contents 1. Some concepts you need to un...

A comprehensive understanding of Vue.js functional components

Table of contents Preface React Functional Compon...

DOM operation implementation in react

Table of contents Previous words Usage scenarios ...

Ajax jquery realizes the refresh effect of a div on the page

The original code is this: <div class='con...

Example of how to install nginx to a specified directory

Due to company requirements, two nginx servers in...

CSS to achieve the small sharp corner effect of bubbles

Effect picture (the border color is too light, pu...

TCP performance tuning implementation principle and process analysis

Three-way handshake phase Number of retries for c...