Creating and configuring a database

RestAuth uses a relational database to store its data. You can use any database supported by Django.

For RestAuth to use the database, you have to create it, configure it and initialize it.

Creating a database


Exhaustive documentation on how to create a database is outside the scope of this document. If in doubt, always consult the official documentation of your database system.


RestAuth requires a database with transactional support. Most notably, the MyISAM MySQL storage engine (which is the default on many systems), does not support transactions. Please use InnoDB instead.


Here is an example shell session for creating a MySQL database:

mysql -uroot -pYOUR_PASSWORD -e "CREATE DATABASE restauth CHARACTER SET utf8;"
mysql -uroot -pYOUR_PASSWORD -e "GRANT ALL PRIVILEGES ON restauth.* TO 'restauth'@'localhost'

The correct DATABASES setting in then would be:

    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'restauth',
        'USER': 'restauth',
        'PASSWORD': 'MYSQL_PASSWORD', # you really should change this!
        'HOST': '',
        'PORT': '',

Please also see the MySQL notes (especially the Creating your database chapter) on the subject. The database tables must not use the MyISAM storage engine, please make sure you use InnoDB or any other engine that supports transactions. Django provides some instructions on how to convert a database to InnoDB.


If you choose to use PostgreSQL, you can create a database like this, assuming you are already the user postgres:

createuser -P restauth
psql template1 CREATE DATABASE restauth OWNER restauth ENCODING ‘UTF8’;

The correct DATABASES setting in then would be:

    'default': {
        DATABASE_ENGINE = 'django.db.backends.postgresql_psycopg2',
        DATABASE_NAME = 'restauth',
        DATABASE_USER = 'restauth',
        DATABASE_PASSWORD = 'POSTGRES_PASSWORD', # you really should change this!
        DATABASE_HOST = '',
        DATABASE_PORT = '',

Please also see the PostgreSQL notes in the Django documentation.


If you are using SQLite, which is not recommended on any production setup, you do not have to do anything except making sure that the directory named in NAME is writable by the webserver.

Configuring the database

RestAuth uses the standard DATABASES setting of Django. Please also see the notes for specific database systems.

To configure your database, just open and edit the DATABASES section near the top of that file.


Once you have created your database and configured it in, you can easily create the necessary tables using the syncdb and migrate commands of restauth-manage:

restauth-manage syncdb
restauth-manage migrate

Table Of Contents

Previous topic

Configuring your webserver

Next topic

Manage a RestAuth server

This Page