Question

How can I put a MySQL database in single user mode? Or even better, in read mode only.

I use select * into outputfile in MySQL side and bcp in in Sybase side to pass data and I want them to be the same in both sides. So, I need the database to remain unchanged.

Is it possible?

Was it helpful?

Solution

Issue a FLUSH TABLES WITH READ LOCK statement before you start to dump, see http://dev.mysql.com/doc/refman/5.0/en/lock-tables.html for more information.

From the sited link:

MySQL enables client sessions to acquire table locks explicitly for the purpose of cooperating with other sessions for access to tables, or to prevent other sessions from modifying tables during periods when a session requires exclusive access to them. A session can acquire or release locks only for itself. One session cannot acquire locks for another session or release locks held by another session.

OTHER TIPS

you can add read_only=1 to my.cnf to put mysql into read only mode

alternatively, you can also SET GLOBAL read_only=1;

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top