Mezzanine CMS, as all Django-based applications, supports different SQL DBs. You can choose the one according to your purposes and preferences, so within the instruction below we’ll reveal how to configure our app to work with:
For the embedded SQLite DB
Being fast, simple and lightweight, SQLite represents a great solution for development and testing purposes.
Tip: For production environments, it’s recommended to use either MySQL-based or PostgreSQL node, as they provide the sufficient level of scalability and security for real-life cases (the detailed instruction for these servers is provided right down the article).
1. The DB connection settings can be seen within the local_settings.py file inside the ~/ROOT/ROOT folder. Here, you’ll find the dedicated DATABASE configuration section with the parameters being stated for the SQLite DB engine usage by default, so you can leave them unchanged in this case.
2. After you’ve reviewed the settings, execute the following line from inside the ~/ROOT directory (i.e. one level above the local_settings.py script location) in order to create a new SQLite database:
python manage.py createdb --noinput
Tip: At this step, the default administration account (with admin/default as credentials), site record and some demo pages are created. If you’d like to specify the data for these options manually, simply run the command above without the '--noinput' option.
The DB itself will be stored in ~/ROOT/dev.db.
3. After the DB is created, you can proceed to the Configuring Apache section of this article a little bit below.
For a separate SQL server
At Jelastic, Mezzanine can be configure to work with any of the provided MySQL-based servers (i.e. MySQL itself, MariaDB or PerconaDB - the settings are completely the same for all of them). Also, you can use PostgreSQL as an option.
Here, we’ll consider the required configuration with the example of PerconaDB 5.6, whilst providing the corresponding settings for Postgres alongside if they differ.
1. So, if you prefer to use a separate DB server - navigate back to Jelastic dashboard, choose the Change environment topology option for your Mezzanine environment, pick up the desired node within the SQL wizard section and click on Apply.
Note: Percona DB is an optional node, since it is based on cartridge packaging model. In case you’d like to use it but can’t find this server in the SQL section of your wizard, send a request to your hosting provider for its enabling.
2. After the node is successfully added to your environment, select Open in browser next to it for the PhpMyAdmin page to be opened. Log in with the credentials you’ve received via email during server installation:
3. Once you’re inside, navigate to the Users tab in order to create a separate account for interaction with Mezzanine CMS database. In the opened frame, click on Add user and specify the appropriate username and password.
Also, tick the Create database with same name and grant all privileges and Grant all privileges on wildcard name (username\_%) options to get a DB with the required privileges. Then press the Go button
Tip: As for the PostgreSQL database, the only necessary action is creation of a new database upon the default DB user.
For that, after being logged in, select the Create database link. Within the appeared input form, specify the name for your new DB, leaving all the rest of settings unchanged, and click on the Create button.
4. After the successful DB creation, return to your console with the opened SSH connection to the Apache Python
server and navigate to the local_settings.py
file inside the ~/ROOT/ROOT
folder. Here, you need to specify the following configurations:
- ENGINE - django.db.backends.mysql (or django.db.backends.postgresql_psycopg2 for PostgreSQL database)
- NAME - type the name of the previously created database (mezzanine in our case)
- USER and PASSWORD - enter the ones you’ve specified during the DB creation (or state the default credentials if using PostgreSQL)
- HOST - internal IP of the chosen DB server
Tip: In order to find out the server’s IP address, expand the Additionally list next to it at the Jelastic dashboard:
PORT - specify the 3306 port number (or 5432nd one if working with PostgreSQL)
As a result, the DATABASES section should look similar to the following:
5. Then, in order to make the server work with MySQL-based DB, the appropriate connector needs to be installed via pip.
pip install MySQL
Tip: To get Python connector for PostgreSQL server, the next command should be run:
PATH=$PATH:/usr/pgsql-9.4/bin/ pip install psycopg2
Please also note that you may need to modify the pgsql-9.4
string according to the provided version of PostgreSQL server at your Jelastic Platform.
6. Once the required SQL module is installed, you can proceed with DB schema creation.
python manage.py createdb --noinput
After the DB is created, let’s ensure the application is operable and apply some additional application server configurations.