# Installation with MySQL

These instructions provide additional steps for setting up Pootle with MySQL.

You should read the full installation instructions in order to install Pootle.

Pootle supports the versions of MySQL supported by Django, make sure that your installed version is supported.

## Setting up the database

Use the mysql command to create the user and database:

    $ mysql -u root -p  # You will be asked for the MySQL root password to log in

    > CREATE DATABASE pootledb CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
    > GRANT ALL PRIVILEGES ON pootledb.* TO pootle@localhost IDENTIFIED BY 'secret';
    > FLUSH PRIVILEGES;

## System software requirements

In addition to the system packages set out in the general installation requirements you will also require the MySQL client development headers in order to build the Python bindings, e.g. on a Debian-based system:

    $ sudo apt-get install libmysqlclient-dev

## Installing MySQL Python driver

Once you have set up and activated your virtual environment, you will need to install the MySQL driver.

You can do so as follows:

    (env) $ pip install Pootle[mysql]

## Initializing the Configuration

When initializing your configuration you can specify params to set up your database, e.g.:

    (env) $ pootle init --db mysql --db-name pootledb --db-user pootle

This will create a configuration file to connect to a MySQL database named `pootledb` hosted on localhost as the user `pootle`. Please see the `init` command for all of the available options.

You will most likely want to edit your Pootle configuration (default location: `~/.pootle/pootle.conf`) to set your password.

## Database backend

### A Note on Persistent Connections

MySQL terminates idle connections after wait_timeout seconds. Thus setting `CONN_MAX_AGE` to a lower value will be fine (it defaults to `0`). Persistent connections where `CONN_MAX_AGE` is `None` can’t be used with MySQL.

To learn more please check Django’s docs on persistent connections and connection management.

    DATABASES = {
        'default': {
            ...
            'CONN_MAX_AGE': 0,
            ...
        }
    }