Set MySQL to Read-Only

For a backup server which we may want to run as read-only for short maintenance periods the following may be useful.
Method 1: Global read_only
Login to MySQL and set the read_only setting to true:

mysql -u root -p
set GLOBAL read_only = true;

To unset this run:

set GLOBAL read_only = false;

Method 2: Read Lock
Another method which will queue queries while the tables are locked and then run them when the tables have been unlocked involves:

FLUSH TABLES WITH READ LOCK;

To revert back use:

UNLOCK TABLES;