Installing MariaDB
A large number of services use to access to the database - web applications, company websites, as well as mail services and various accounting systems. Today we will consider installing one of the most popular DBMSs - MariaDB.
In this article we will not consider how to install and configure a LAMP server. It should be noted that the MySQL server in the repositories has been replaced by MariaDB due to the openness of the code and the active development of the project itself.
We add the repository since the system will install the version of MariaDB 5.5. For each OS, we consider this moment separately. If this suits you, then you can skip this step. If you still decide to do this, then open the page on the official website with information about repositories and their settings.
Ubuntu
Before installing, we update the data on repositories and package indices:
sudo apt-get update
We update packages and system components:
sudo apt-get upgrade
We reboot the system, sometimes it is required:
sudo reboot
Check the version of the MariaDB-server package in the repository:
apt-cache show mariadb-server
For Ubuntu 16.04 the answer is as follows:
For Ubuntu 18.04:
Add information about the repository with version 10.3. Important: each version of Ubuntu has its repositories.
For Ubuntu 16.04, we execute the following commands in turn:
sudo apt-get install software-properties-common
sudo apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xF1656F24C74CD1D8
sudo add-apt-repository 'deb [arch=amd64,arm64,i386,ppc64el] http://mirror.timeweb.ru/mariadb/repo/10.3/ubuntu xenial main'
For Ubuntu 18.04:
sudo apt-get install software-properties-common
sudo apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xF1656F24C74CD1D8
sudo add-apt-repository 'deb [arch=amd64,arm64,ppc64el] http://mirror.timeweb.ru/mariadb/repo/10.3/ubuntu bionic main'
Update the contents of the repositories and complete the installation:
sudo apt-get update
sudo apt-get install mariadb-server
Regardless of the version of Ubuntu, the installer will require you to enter the root password and confirm it:
CentOS
We update system components, and at the same time data on repositories
sudo yum update
Add repository for stable version 10.3. To do this, go to the directory with the repository files and create a file:
cd /etc/yum.repos.d/
sudo touch MariaDB.repo
Data from the official site is added to the file by any editor:
# MariaDB 10.3 CentOS repository list - created 2019-05-07 06:43 UTC
# http://downloads.mariadb.org/mariadb/repositories/
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.3/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
Install the package:
sudo yum install MariaDB-server MariaDB-client
The yum program will collect all the necessary data for the installation and will wait for the user:
We answer the question “y” and press Enter. The number of packages you can install may be different.
КThe command should be re-run if the following error occurs:
Error downloading packages:
MariaDB-compat-10.3.14-1.el7.centos.x86_64: [Errno 256] No more mirrors to try.
MariaDB-client-10.3.14-1.el7.centos.x86_64: [Errno 256] No more mirrors to try.
MariaDB-common-10.3.14-1.el7.centos.x86_64: [Errno 256] No more mirrors to try.
After installation, you should start the server:
sudo service mysql start
Setup
Most programs are installed with default settings. Regardless of the distribution, we recommend that you optimize your security settings.
sudo mysql_secure_installation
Yes, it’s “mysql” because the MariaDB project has "leaked" from MySQL.
At the very beginning, the program will ask for the password for the root user. If the password has not been set, then press Enter. Most questions can be answered with “y”. Questions and translation are listed below:
- Change the root password? [Y/n]
- Remove anonymous users? [Y/n]
- Disallow root login remotely? [Y/n]
- Remove test database and access to it? [Y/n]
- Reload privilege tables now? [Y/n]
Check server status
Sometimes it may be necessary to check the status of the server. This operation can be performed with the command:
sudo service mysql status
It should be noted that if the server is not running, then it must be started in manual mode with the command:
sudo service mysql start
Testing the connection to the DBMS
Connection to the DBMS is performed by the following command:
mysql -u <USER_NAME> -p
If this is the first connection and no other users have been added, you should connect from the root user:
mysql -u root -p
Then enter the root password; if no password has been set, press Enter.
Exiting the shell by the command:
exit