I need to turn one database into read-only, so I can clone the database and make schema modifications on the clone before we switch the application to the new database. I know the way to turn the MySQL database server into read-only, but that will make it impossible to do the schema change on the new cloned database.
I searched and didn't find any answer. I suspect there is no such feature. In that case, what would you recommend for upgrading a live database without pausing the service?
To turn it off, you can use the SET GLOBAL statement as shown below: SET GLOBAL read_only=0; The option should now be turned off.
Hold down Ctrl and press Enter to execute the SQL. You can edit the SQL afterward when you run it without getting an error. Before that, run a SELECT query to view the table data. The "Read Only" text has changed to a disabled Apply button.
If read_only is set to 1, then the SET PASSWORD statement is limited only to users with the SUPER privilege (<= MariaDB 10.5. 1) or READ ONLY ADMIN privilege (>= MariaDB 10.5. 2). Attempting to set the read_only variable to 1 will fail if the current session has table locks or transactions pending.
You could revoke write access for specific users during this period.
You could revoke update/insert/delete privilege on the account that is using that database. If the application is logged in as root then you have bigger problems on your hands.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With