Restrict MySQL from server to read-only state

Source: Internet
Author: User

There are two ways to modify a global variable, the first of which is to modify the configuration file, and the second is to set the value of the global variable by the SQL statement. (Refer to: http://www.cnblogs.com/qlqwjy/p/8046592.html)

0. Introduction:

  For the database read and write state, mainly rely on "read_only" global parameters to set; By default, the database is used for read and write operations, so the READ_ONLY parameter is also a 0 or faluse state, both local users and remote access to the database can read and write operations , set the READ_ONLY parameter to 1 or true if you want to set it to read-only state, but there are two places to be aware of when setting the Read_only=1 state:
1.read_only=1 read-only mode, does not affect the functionality of slave synchronous replication, so after Read_only=1 is set in the MySQL slave library, the slave status is viewed through the show Status\g Salve command. You can see that salve still reads the log on master and applies the log in the slave library to ensure that the master-slave database is synchronized;
2.Read_only=1 Read-only mode, can limit the normal user to make data modification operation, but does not restrict the user with Super permission data modification operation; after setting read_only=1 in MySQL, normal application users insert, When a DML operation that generates data changes, such as update, delete, and so on, will report that the database is in read-only mode without data changes, but users with super privileges, such as logging in to the database locally or remotely through the root user, or DML operations that can make data changes;

3.super_read_only is limited to the permissions of a user with root privileges, so this variable is set to on when the root user can only view and not modify. (so you need to set two variables to either on or 1), modifying this variable will not affect the master-slave copy

If the value is off or 0, you can read and write

If set to ON or 1 is read-only

1. There are two global variables related to MySQL read and write status;

 like ' %read_only% '

2. Set global variable super_read_only to ON

SET GLOBAL super_read_only=1 #或者为on

  

3. View the value of the global variable again

 like ' %read_only% '

  

4. Test modify a value found not allowed to modify

Restrict MySQL from server to read-only state

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.