How do I set MySQL temporarily to read-only through the command line?

前端 未结 3 1453
刺人心
刺人心 2020-12-12 17:33

I\'m creating a bash script which, among other things, gathers some data from a MySQL database. My MySQL user has write privileges, but for safety reasons I would like to te

3条回答
  •  离开以前
    2020-12-12 17:49

    If you're using MySQL 5.6 or newer and InnoDB, you can make a session read-only.

    SET SESSION TRANSACTION READ ONLY;
    

    https://dev.mysql.com/doc/refman/5.6/en/set-transaction.html

    "READ ONLY" also offers a modest performance benefit.

提交回复
热议问题