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

The method of adding read-write Lock in mysql

2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

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

This article will explain in detail how to add read-write locks to mysql. The content of the article is of high quality, so the editor will share it with you for reference. I hope you will have a certain understanding of the relevant knowledge after reading this article.

Read lock: (shared lock shared lock)

Read locks are shared, or do not block each other. Multiple customers can read the same resource at the same time without interfering with each other.

Write lock: (exclusive lock exclusive lock)

The write lock is exclusive, that is, one write lock will block other write and read locks, which is due to security policy considerations, so as to ensure that only one user can perform a write at a given time. And prevent other users from reading the same resource that is being written.

How to add mysql read-write locks:

1. First, I log in to mysql from the command line and execute the command show databases; to see how many databases there are.

2. Execute show to check how many database tables there are, and select * from ceshi to query the data of the tables in the table.

3. Execute lock table ceshi read; to lock the ceshi table.

4. In another process, the table ceshi is also readable, and writing will be delayed. When a read lock is added to the table, the permission to read and write may be banned or delayed.

5. Add a table write lock lock table ceshi write to the table

6. When a table is written locked in a process, the process itself has read and write permission to the table, while other processes have neither read nor write permission to the table.

On the mysql to add read-write lock method to share here, I hope the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.

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