Manual:$wgReadOnly

Details
If set to a string (e.g., in LocalSettings.php), $wgReadOnly disallows editing, displaying the string given as the reason. Functionally the same as $wgReadOnlyFile, but using a variable instead of a file.

Note that some of your installed extensions may write data nonetheless.

The above example locks the database and provides a default statement on edit pages and also gives the included string 'site maintenance' as an explanation for why the database was locked.

Warning
In some versions of Mediawiki (like v. 1.12.0 in Debian Lenny), this setting may make all page loads extremely slow (dozens of seconds before the page is shown).