Skip to content

mariaDB

Sarai Varona edited this page Jun 24, 2019 · 10 revisions

iSkyLIMS uses MySQL/mariaDB as database to store all information.

MySQL: mariaDB installation

For CentOS:

Edit the next file to add mariaDB repository.

vim /etc/yum.repos.d/mariadb.repo

Add the following lines:

## Add content to file. IMP:  
#Installed version: 10.1 version because bug with mysqlclient 
# (python) bug compilation (cannot find -lmariadb)
# MariaDB 10.1 CentOS repository list - created 2018-02-06 03:42 UTC
# http://downloads.mariadb.org/mariadb/repositories/
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.1/centos6-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1

Once the repository path is added, install mariaDB using yum

yum install MariaDB-server MariaDB-client MariaDB-devel 

For Ubuntu:

apt-get install software-properties-common
apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xF1656F24C74CD1D8
add-apt-repository 'deb [arch=amd64,arm64,ppc64el] http://mirrors.up.pt/pub/mariadb/repo/10.1/ubuntu bionic main'
apt update
apt install mariadb-server mariadb-client libmariadb-dev libmariadbclient-dev libmariadbd-dev

IMPORTANT

When installing MariaDB software, it will prompt for setting the root password.

For security reason you must define it.


Start database service

Start the MySQL service by typing:

/etc/init.d/mysql start

Configure mysql

mysql_secure_installation

Enter the root password, you defined before.

Type “y” for all questions.

Next step involves the definition of the django user in the database of mariaDB. To do so the following steps will be performed:

mysql -u root -p 
## enter the root password defined before

Once in mysql, choose a password (let's refer to it as the chosen-password. Note that you will reuse it in a further step) and type the following commands:

CREATE USER 'django'@'localhost' IDENTIFIED BY '<type_your_password>';

GRANT ALL PRIVILEGES ON * . * TO 'django'@'localhost';

Create iSkyLIMS database:

CREATE DATABASE iSkyLIMS;
# The next command is recommended to execute, to avoid error when trying to store specials characters like accents in database.
ALTER DATABASE `iSkyLIMS` CHARACTER SET utf8;

Check that bin log is disabled

# Enter this command to get the value of bin_log
SHOW VARIABLES LIKE 'log_bin';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| log_bin       | OFF   |
+---------------+-------+
1 row in set (0.00 sec)

# You should get that the value is OFF. But if the variable is set to ON 
# you need to change in msql config file

# Exit
quit; 

Only if log_bin is ON

To modify this variable edit the file mariadb.cnf to add the option disable_log_bin

vim /etc/mysql/conf.d/mariadb.cnf

Write the option disable_log_bin and save the file

[mysqld]
disable_log_bin

### Restart the mariadb service to apply the changes
service mysql restart

Connect again to database to check that the value has changed

MariaDB verification

Before move on to the next chapter we are going to verify that django user is allow to connect to database.

mysql -u django -p 
Enter password:  ## enter the root password defined before

You should get a printout similar to this:

Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 32
Server version: 10.1.38-MariaDB-1~bionic mariadb.org binary distribution

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

# Type quit to return to shell prompt

quit;
Clone this wiki locally