0

Set particular database temporarily to read-only through the command line while connecting db ?

Note : Want to prevent UPDATE/DELETE operations

Like - < --i-am-a-dummy >, it prevents to update/delete a table without a WHERE clause, But I dont want update/delete with/without WHERE.

Yes, I can create user, however, is it possible at connection time ?

This would set it permanently, and I don't want it permanently.

/bin/mysql -uroot -ppass --execute="GRANT SELECT ON 'maindb'@.* TO 'root'@'localhost';FLUSH PRIVILEGES;"

  • Rolando already answered this question but his solution applies to the whole server. dba.stackexchange.com/questions/74670/… – Craig Efrein Aug 6 '15 at 10:03
  • @CraigEfrein, Thank you for reply. Well, I want an option like this if available, < --i-am-a-dummy >, while connection is set or the instance is created, and with the instance is destroyed, it should be normal as same. – Hytool Aug 6 '15 at 10:07
  • Not quite sure I understand what you mean by - it should be normal as same – Craig Efrein Aug 6 '15 at 10:10
  • we create a connection manually with command line by, bin/mysql maindb -uroot -pmypass --i-am-a-dummy, Now, here, I want something like < --i-am-a-dummy > which prevents UPDATE/DELETE operations for this connection. < --i-am-a-dummy > only prevents update/delete without WHERE clause. – Hytool Aug 6 '15 at 10:16
  • The only thing I've found is what Rolando already explained. You can either revoke permissions or put MySQL into read_only=1 mode. The iamadummy option isn't comparable because it doesn't prevent or avoid writing to the databases – Craig Efrein Aug 6 '15 at 10:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.