سؤال

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?

هل كانت مفيدة؟

المحلول

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.

نصائح أخرى

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;

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top