Manual:Lock the database

Set  in LocalSettings.php to the name of a file, then put the reason for the lock inside the file. The contents of the file will be displayed to anyone trying to edit the wiki.

Since mediawiki 1.5 you can set  to a string describing the reason for read-only mode, instead of creating a file. (Usual wiki markup is allowed in this string).

$wgReadOnly="We are upgrading mediawiki, please be patient. This wiki will be back in a few hours.";

Note that readonlyfile is not guaranteed to be absolutely safe; if you need to guarantee that MediaWiki will never write to the data, you need to do this on the database itself (e.g. revoke UPDATE,INSERT,DELETE from the wiki user, or put MySQL into read-only mode).