# MySQL

There are a few simple reasons why we chose MySQL when picking a database backend for LiveJournal: It's fast, free, stable, secure, and well supported by a large community of users. In this chapter we'll deal with installing and setting up MySQL on your server, then we'll show you how to populate your installation with the required base data.

## Install MySQL

LiveJournal requires a MySQL install of at least version 3.23.x, but highly recommends installing the latest stable release that is available, expecially if you're going to need clustering and replication abilities.

MySQL offers binaries for many operating aystems, including Win32 and several different flavors of Unix. Installations on any of these systems should be fairly easy, as most offer a simple installation program that guides you through setup.

### Debian

The MySQL server package for Debian is `mysql-server`.

## Create the LiveJournal Database

Login to MySQL as the root MySQL user and create the database that will hold the LiveJournal data:

    $ mysql -uroot -p
    mysql> CREATE DATABASE livejournal;
    mysql> GRANT ALL PRIVILEGES ON livejournal.* TO
         > lj@'localhost' IDENTIFIED BY 'ljpass';

If you know what you're doing, you can set this up however you like. You tell LiveJournal how to connect to its database server(s) in your `ljconfig.pl`, as detailed in: .

## Populate the Database

In order to use your site, you're going to need to populate your MySQL database with the required information to get the service started.

    $ cd $LJHOME
    $ bin/upgrading/update-db.pl --runsql --populate
    $ bin/upgrading/texttool.pl load

That'll bring your database schema up-to-date and populate it with any look-up data it needs.