How to Install MariaDB 10.5 on Ubuntu 18.04, Ubuntu 20.04
This tutorial will be showing you how to install MariaDB 10.5 on Ubuntu 18.04 and Ubuntu 20.04 server. MariaDB is a mature, stable, open-source relational database forked from MySQL. Most Linux distributions have replaced MySQL with MariaDB as the default database server. MariaDB powers applications at companies and organizations including Google, Wikipedia, Tencent, Verizon, Deutsche Bank, Huatai Securities and more.
At the time of this writing, the latest stable version is MariaDB 10.5.4, released on June 24, 2020. Notable changes include:
- A new S3 storage engine, which stores data in Amazon S3
- It now includes the CloumnStore storage engine, which is a columnar storage engine that utilizes a massively parallel distributed data architecture.
- New Gamma version of the Spider Storage Engine
- DROP TABLE now reliably deletes table remnants inside a storage engine even if the .frm file is missing
- Accelerated crc32() function for AMD64, ARMv8, POWER 8 (MDEV-22669)
- InnoDB Performance improvements
- And more.
Every major MariaDB release will be maintained at least 5 years, so MariaDB 10.5 will be supported until June, 2025.
Install MariaDB 10.5 on Ubuntu 18.04, 20.04 From Official Repository
The default Ubuntu repository includes MariaDB package, but the version is out of date. Ubuntu 18.04 contains only MariaDB 10.1 and Ubuntu 20.04 contains MariaDB 10.3. We can install the latest version from the official MariaDB repository.
Visit https://downloads.mariadb.org/mariadb/repositories and select your Linux distribution, release, version, and the repository mirror that you would like to use. For example, I selected Ubuntu 20.04, MariaDB 10.5 and the Limestone Networks mirror, as shown in the following screenshot.
Once all of the choices have been made, customized instructions will appear at the bottom of the page. As an example, I need to run the following commands to add the repository on Ubuntu 20.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.lstn.net/mariadb/repo/10.5/ubuntu focal main'
To add the repository on Ubuntu 18.04, simply replace focal
with bionic
in the third command.
Then update package index and install MariaDB server.
sudo apt update sudo apt install mariadb-server
The galera-4
package will be installed automatically with the MariaDB server. If you are upgrading an existing MariaDB server to the latest version, you might see the following message. I recommend choose N to keep the current version and examine what needs to change later.
Once the installation finishes, MariaDB server automatically starts. You can check its status with:
systemctl status mysql
or
systemctl status mariadb
As you can see, it’s active and running.
Hint: Press Q to gain back control of the terminal if the above command doesn’t quit immediately.
If it’s not running, you can manually start it with:
sudo systemctl start mariadb
To enable auto-start at boot time, run
sudo systemctl enable mariadb
To log in to MariaDB monitor, run
sudo mysql -u root
or
sudo mariadb -u root
If you are asked to enter a password, you need to enter the password for your user’s sudo password, not the MariaDB root user password.
We can see that the server version is 10.5.4, installed from mariadb.org binary distribution. To log out, run
exit;
Run the Post Installation Script
To secure MariaDB server as much as possible, run the post-installation script.
sudo mysql_secure_installation
MariaDB 10.5 uses unix_socket authentication plugin, so the MariaDB root user doesn’t need a password. When the script asks you to enter the password for root, just press Enter. Answer “n” to the next two questions.
Then you can press Enter to answer all remaining questions, which will remove anonymous user, disable remote root login and remove test database. This step is a basic requirement for MariaDB database security. (Notice that Y is capitalized, which means it is the default answer. )
InnoDB vs XtraDB Storage Engine
By default, until MariaDB 10.1, MariaDB uses the XtraDB storage engine, a performance enhanced fork of the InnoDB storage engine from MySQL. However, over time, MySQL has implemented almost all of the improvements. InnoDB has caught up, so from MariaDB 10.2, InnoDB is the default engine.
To check which is the default storage engine, log into MariaDB monitor and run the following command.
show engines;
On MariaDB 10.1, the above command returns the following result, which indicates XtraDB is the default engine.
On MariaDB 10.5, the above command returns the following result, which indicates InnoDB is the default engine.
Troubleshooting
If during the installation process, you encounter an error like below:
dpkg: dependency problems prevent configuration of mariadb-server: mariadb-server depends on mariadb-server-10.5 (= 10.5.5+maria-1~); however: Package mariadb-server-10.5 is not configured yet.
That’s probably because your previously installed MariaDB/MySQL server is still running. To fix this error, you need to stop the currently running mysqld
process.
sudo kill -9 $(pgrep mysql)
And run the install command again.
sudo apt-get install mariadb-server mariadb-client
Check MariaDB status:
systemctl status mariadb
We can see that it’s running.
● mariadb.service - MariaDB database server
Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; vendor preset: enabled)
Drop-In: /etc/systemd/system/mariadb.service.d
└─migrated-from-my.cnf-settings.conf
Active: active (running) since Sun 2020-07-05 01:30:09 CST; 1min 57s ago
Process: 26932 ExecStartPost=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS)
If the above method doesn’t work for you, then check out MariaDB error log /var/log/mysql/error.log
to find out the cause.
How to Examine Differences Between the Old and New Configuration File
As I said before, if you upgrade an existing MariaDB server to the latest version, you might see the following message. I recommend choosing N to keep the current version and examine what needs to change later.
Go to the MariaDB configuration directory.
cd /etc/mysql/mariadb.conf.d/
The old server configuration file is 50-server.cnf
and the new configuration file is 50-server.cnf.dpkg-dist
. Use the diff
utility to compare the two files.
sudo diff -y 50-server.cnf 50-server.cnf.dpkg-dist
The could be some new settings in MariaDB 10.5 and you should apply these new settings to your current config file.
Conclusion
That’s it. I hope this article helped you install MariaDB 10.5 on Ubuntu 18.04 and Ubuntu 20.04. You may also want to read:
If you like to manage MariaDB Database From a web interface, you can use phpMyAdmin.
- How to Install phpMyAdmin with Apache (LAMP) on Ubuntu 20.04
- How to Install phpMyAdmin with Nginx (LEMP) on Ubuntu 20.04
As always, if you found this post useful, then subscribe to our free newsletter to get more tips and tricks. Take care 🙂
Hello Xiao,
I did un upgrade of MariaDB to the Stable Version – 10.5 for ubuntu 20.04LTS – and now i cant “sudo mariadb -u root” because it answer with this:
ERROR 1045 (28000): Access denied for user ‘root’@’localhost’ (using password: NO).
but if i do “sudo mariadb -u root -p” and enter the password it works.
Any clue why this is happening?
—
Kindest Regards,
If you would like to continue to use the unix_socket method, then edit the 50-server.cnf file.
Add the following line in the [mariadb] unit at the bottom.
Save and close the file. Then restart MariaDB server for the change to take effect.