MariaDB, le fork libre de MySQL

How to install MariaDB on Raspbian and the Raspberry Pi

Updated the 29 January 2018 - 9 Comments - , , , , , ,

ⓘ Cet article peut avoir été partiellement ou totalement traduit à l'aide d'outils automatiques. Nous nous excusons des erreurs que cela pourrait engendrer.

Now Raspbian install MariaDB by default instead of MySQL. To see how to install MySQL, take a look here.

In the last tutorial, we showed you how to replace Apache by Nginx for your Raspbian system, in order to get a faster and less RAM-consuming web server.

Today, we will continue to optimize our web server on the Raspberry Pi by interesting us to the database. So we’ll see how to install MariaDB on the Raspberry Pi.

What is MariaDB?

Before we go to the installation, let’s talk a little more about MariaDB, what it is and what it serves.

Until now, we talked about MySQL, which is probably the most used DBMS (at least 56% market share on free technologies). But MySQL is not alone in the world of free DBMS and all its competitors, the most serious is undoubtedly MariaDB, whether by its market shares (18%), by its functionalities, very similar to those of MySQL , Or by its perfect compatibility with MySQL. Not surprisingly, since the creator of MariaDB (Michael Widenius) is also the creator of MySQL.

Why did Michael Widenius create MariaDB instead of continuing to improve MySQL?

To find the answer to this question, you have to make a small jump back in the history of MySQL.

In 1995 Michael Widenius founded MySQL AB, an open source software company, and soon became a major player in the database industry.

In 2008, MySQL was bought for $ 1 billion by Sun Microsystems, another major player in the field of open source software.

In 2009, Sun Microsystems was acquired by Oracle, and MySQL with it.
It is at this moment that everything will change. There were real concerns about Oracle’s willingness to maintain and evolve MySQL in an open source and free way, with Oracle already offering a competing, paying, proprietary solution for large companies, the well-known Oracle Database.

In 2009, Michael Widenius leaves Sun on his redemption, get back the source code of MySQL (free software) and launches a petition to pressure Oracle to continue to develop MySQL.

In order to ensure that the code of MySQL remains free, and that it does not disappear, Michael Widenius will then create a new DBMS, fork of MySQL (a fork is a software created from the source code of another).

He will name this DBMS after his second daughter name, Maria, as he had done with MySQL and his first daughter, My.

A foundation will then be create, the MariaDB Foundation, to ensure the governance of the project.

Since then, MariaDB develops more and more every day, continuing to ensure compatibility with MySQL and improving it.

Why use MariaDB on the Raspberry Pi

Eventually, MySQL always develops, and is still free, so why install MariaDB instead of MySQL on the Raspberry Pi?

First of all, because MySQL is distributed by Oracle, and Oracle is not very well seen in the world of free software, often preferring a proprietary logic, which is both stupid and wrong! Then, because MySQL may not remain open-source for a very long time, it is already dual-licensed, free and proprietary. Also, because MariaDB is 100% compatible with MySQL, and so there is no reason not to. Finally, and this is probably what will interest you most, for performance issues.

If MariaDB is increasingly used, it is not just because it is more open source than MySQL, but mainly because it is more efficient.

Indeed, benefiting from a large community of developers, and the experience of its creator, MariaDB presents performances superior to MySQL, while being perfectly compatible with this one. This means that to improve your site, simply install MariaDB instead of MySQL, and you will not even need to change the code of your website and applications!

MariaDB has a real performance improvement compared to MySQL, especially on complex queries. This is due in part to the use of the Aria engine rather than the InnoDB engine and the optimization efforts at the heart of the MariaDB project (you can find comparisons between MariaDB and MySQL on this point at this address).

This is due in part to the use of the Aria engine rather than the InnoDB engine and the optimization efforts at the heart of the MariaDB project (you can find comparisons between MariaDB and MySQL on this point at this address).

To give you an idea of ​​this difference, here is a quick benchmark comparing MariaDB and MySQL.

MariaDB benchmark against MySQL shows MariaDB winner

Performance Comparison for MySQL and MariaDB.
In blue, MySQL 5.5.21
In green, MySQL 5.6.4
In red, MariaDB 5.3.6
Source: http://blog.mariadb.org

And unlike Nginx and Apache, there is no real counterpart to the advantages of MariaDB over MySQL. You will have nothing else to do but disable MySQL and install MariaDB.

MariaDB is therefore a perfect choice for a Raspberry Pi using Raspbian, since the RAM resources are limited, with only 1 GB for the Raspberry Pi 3 (by the way, if you do not already have it, you can find it here on Amazon) and only 512MB for the Raspberry Pi Zero (which you can find there).

Install MariaDB on Raspbian

With the new version of Raspbian, MariaDB is now present in the official repositories, which until now was not the case!

To install it, nothing more simple therefore, you just need to run the following command:

sudo apt-get install mariadb-server

If you already have MySQL installed, it is likely that the package manager notifies you of a conflict and asks if it needs to uninstall MySQL. In this case, answer yes.

During the installation, MariaDB will configure itself. It’s up to you to provide the administrator account for the database.

This done, it should ask you if you are sure to want to go under MariaDB. Again, answer yes.

Once the installation is complete, you will be able to access MariaDB as you did with MySQL, simply with the following command:

mysql -u user -p

Conclusion

Here, you now know how to install MariaDB on the Raspberry Pi.

As you may have seen, during this tutorial we have often referred to Nginx, and it’s not for nothing. Indeed, the couple Nginx / MariaDB is more or less the modern equivalent of the pair Apache / MySQL. We strongly encourage you to use Nginx with MariaDB for an ever faster web server!

Alternatively, you can also check out our tutorials around the accessories of the Raspberry Pi or about how to create a media center with the Raspberry Pi!

3/5 - (5 votes)
Share
Newsletter
Author:
Raspberry Pi FR
Join the Raspberry Pi community
A $35 computer already sold 10 million copies
BUY THE NEW RASPBERRY PI 4
Related tutorials
Create a Wi-Fi hotspot in less than 10 minutes with Pi Raspberry! Install Android on his Raspberry Pi How to install a web server on the Raspberry Pi (Apache + PHP + MySQL) Create a NAS with your Raspberry Pi and Samba Install WordPress on a Raspberry Pi (with Nginx).
9 Comments

  1. Eva says:

    After installing you should run sudo mysql_secure_installation to set a password

  2. Dennis says:

    Myphpadmin works with either Apache or Lighttpd. Nginx isn’t an option in the installation and it appears there are some steps to go through to make it work with Nginx.

  3. p.gersche says:

    How can i Import a mysql db backup from my site to mariadb?
    Aer there any known issues between mysql and mariadb?

    Thanks

    1. You can import it just like with MySQL, no issues between thoses.

  4. Roger Manich says:

    to run maria db: sudo mysql -u root

    1. Yep, since few version now raspbian have replace mysql by mariadb by default

  5. Dmitri says:

    And what is default password?

    pi@raspberrypi:~ $ mysql -u user -p
    Enter password:
    ERROR 1698 (28000): Access denied for user ‘user’@’localhost’

    1. You should use sudo, but actually this tutorial is not so relevant anymore as mariadb came by default istead of mysql now.

Share
Newsletter Sign-Up
Subscribe to the newsletter.
¿Te gustó este artículo?
¡Suscríbete y mantente informado!