2.5. Database Server Installation

2.5.1. MySQL

2.5.1.1. Intro

That very popular database server is available with majority of Linux distributions. If, however, you have to install it yourself, start with downloading its sources from www.mysql.com.

2.5.1.2. MySQL Server Installation

After extracting, go to directory with MySQL and type this sequence of commands:

$ ./configure --prefix=/usr/local/mysql
$ make
$ make install
$ /usr/local/mysql/bin/mysql_install_db
$ chown mysql -R /usr/local/mysql/var
$ /usr/local/mysql/bin/safe_mysqld &
$ /usr/local/mysql/bin/mysqladmin -u root password new_password

2.5.1.3. Create Database

You have to create database if you run LMS for the first time. In order to create database and load it with schema go to LMS directory and run:

mysql -u[user name with database creation rights] -p
Enter password:[just enter password :)]
mysql> CREATE DATABASE lms CHARACTER SET utf8 COLLATE utf8_polish_ci;
mysql> GRANT USAGE ON lms.* TO lms@localhost;
mysql> GRANT ALL ON lms.* TO lms@localhost IDENTIFIED BY '[your_password]';
mysql> flush privileges;

2.5.1.4. LMS Configuration (lms.ini)

Because MySQL is default database for LMS, configuration is limited to [database] section setup. Thus you need to edit /etc/lms/lms.ini and fill in password and user's name:

user     = lms
password = your_password

After this step you should be able to enter your system without any problems. Just write an URL for your LMS installation. If there's no user account (first run), you'll be prompted with form to add username and some personal data. When you enter correct admin personal details LMS will move you to login page, where you can use newly created account.

Let's stop here and add some stuff to cron, for peace of mind:

12 4 3,10,17,21,28 * * /usr/bin/mysqldump -u lms --password=your-super-secret-password \
              --add-drop-table --add-locks lms > backups/lms-auto-"$(date +%s)".sql

That will create mysql database backup automagically each 3, 10, 17, 21 and 28 day of month at 4:12 at night.

2.5.2. PostgreSQL

2.5.2.1. Intro

LMS require PostgreSQL 8.4 or higher. If you have not installed PostgreSQL server, you can compile it yourself from sources available on www.postgresql.org.

2.5.2.2. Installation

That is a short version of installation procedure, more info can be found in Postgres documentation. After you download and extract sources go to main directory and run following commands:

$ ./configure --enable-locale
$ gmake
$ su
$ gmake install
$ adduser postgres
$ mkdir /usr/local/pgsql/data
$ chown postgres /usr/local/pgsql/data
$ su - postgres
$ /usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data --locale=pl_PL.UTF-8
$ /usr/local/pgsql/bin/postmaster -D /usr/local/pgsql/data >logfile 2>&1 &

Warning

Applies to version <= 9.1.x: It's required to add in postgresql.conf: custom_variable_classes = 'lms'

2.5.2.3. Database Creation

While server is running you can start with adding database and its owner, both named 'lms' and loading database schema:

$ /usr/local/pgsql/bin/createuser -DPRS lms
$ /usr/local/pgsql/bin/createdb -E UNICODE -O lms lms

2.5.2.4. LMS Configuration (lms.ini)

For LMS default database server is MySQL so you have to set following options in [database] section of /etc/lms/lms.ini file:

type     = postgres
user     = lms
password = password_entered_with_lms_user_creation

Note

The need for password actually depends on Postgres users authentication configuration found in /usr/local/pgsql/data/pg_hba.conf (refer to Postgresql documentation). By default password is not required and you can comment it with semicolon.

After this step you should be able to enter your system without any problems. Just write an URL for your LMS installation. If there's no user account (first run), you'll be prompted with form to add username and some personal data. When you enter correct admin personal details LMS will move you to login page, where you can use newly created account.

Let's stop here and add some stuff to cron, for peace of mind:

12 4 3,10,17,21,28 * * /usr/bin/pg_dump -U lms --clean \
                       lms --file=backups/lms-auto-"$(date +%s)".sql