Installing MariaDB
Once we have chosen a MariaDB version, we can proceed to install it. This section covers the installation process on various systems.
All MariaDB packages can be downloaded from https://downloads.mariadb.org/. On Linux, a repository can be used to download the software and automate the upgrades. More details on this topic are provided in the Installing on Linux subsection.
Installing on Windows
MariaDB can be used on a Windows system in the following three ways:
- Normal installation
- Installation as a Windows service
- By using the
noinstall
package
Installing MariaDB as a service means that it will be started on system boot and stopped properly on system shutdown. If MariaDB is not installed as a service, we will need to start and stop it manually.
The noinstall package
The noinstall
package is a ZIP archive that allows us to execute MariaDB on Windows systems without installing it. This is not the optimal way for executing MariaDB; however, this allows us to start using it quickly. For testing purposes, studying purposes, or for any trivial usage, a noinstall package can be acceptable.
To start using MariaDB without installation, all we have to do is to unpack the archive using a file archiver utility that is able to work with the ZIP format.
Note
A good open source program that we can use is 7-zip. It can be downloaded from www.7-zip.org.
MariaDB can be copied to any path, and any valid name can be used for its directory. Commonly used paths for MariaDB on Windows are C:\MariaDB and C:\MariaDB 10.0
.
The package for Microsoft Installer
MariaDB can be installed on Windows from a .MSI
package. It displays a graphical interface, which guides us through some simple steps, as follows:
- Open the
.MSI
file to use the Windows installation wizard. - This allows us to install MariaDB normally or as a service. We will go through a series of simple steps. We are supposed to read the informative text and set some available options.
- Click on the Next button. A Back button is also available in case we are not sure about the previously set options. A Cancel button allows us to abort the installation process.
The first step is merely a welcome text which informs us about the MariaDB version that we are going to install.
Then we are asked to accept the GPL license, which states the user's rights. We have a Print button here in case we prefer to read the license on paper.
To be able to go to the next step, we need to declare that we accept the license by checking the I accept the terms in the License Agreement checkbox, as seen in the following screenshot:
In the next step, we are asked to select the components to be installed. The component Database instance is necessary for a new installation. But this step can be skipped if we want to use an existing database, perhaps one created with an older version of MariaDB or with MySQL. However, in this case, please go through the Upgrading MariaDB section given later in this chapter for details.
Then we are asked to set some basic options. First, we need to choose a password for the user root. We need to set this twice. If we skip this, the root user will have no password. This is acceptable if we are just installing MariaDB on our local machine for development purposes, but is usually a bad idea in other cases. Moreover, disabling remote access for the root user is usually recommended.
By creating an anonymous account, we allow non-authenticated users to access MariaDB. This can be convenient on a local development machine, but, again, this is generally a bad practice in other cases.
By default, MariaDB uses the latin1
character set. This is usually acceptable for American users as well as many European users, though with latin1
, it is not possible to store names using non-Latin character sets. Nowadays, in most cases, it is preferable to use UTF8
or UTF8MB4
.
Now we need to decide if we want to install MariaDB as a service or not. If it is installed as a service, it starts at the time of system startup, and gracefully stops on system shutdown. In this case, the default name for the service is MySQL for compatibility reasons, but we can change it. We can also change the port number. The Optimize for transactions option should usually be checked. It means that InnoDB will be used as the default storage engine, which is the optimal choice in almost all situations. We are also asked to set the size for the InnoDB cache. For production purposes, it's a good choice to set it up at two-thirds of the available memory. It should also be able to contain all the data that we store in the InnoDB tables. If we are not sure, we can use the default value.
We are also asked if we want to install the Feedback plugin. This plugin, when active, periodically sends our database's usage statistics to the MariaDB project servers. No private data is sent.
Finally, MariaDB is installed, and we receive a message that informs us that the installation was successful.
Installing on Linux
Some Linux distributions include MariaDB in their repositories. If we use one of those distributions, we can easily install MariaDB with a trivial command-line statement or even a graphical utility. In this case, we can check our system's documentation to find out the way to install MariaDB or, more generally speaking, any software package.
However, we may prefer to use the official MariaDB packages and the official MariaDB repositories. If we do so, we can choose any of the MariaDB versions. Moreover, the official repositories guarantee that we are constantly up-to-date with the latest features and bug fixes.
The MariaDB-generic Linux binaries are also available. These packages can be used on any Linux distribution for which a specific package is not available. They also allow a more customized installation: for example, with these binaries, we can install MariaDB in any path we choose. However, note that, if we choose to use a generic binary, we will need to take care of the dependencies.
Using official repositories
If we want to use the MariaDB official repositories, we need to configure our system before installing MariaDB.
The MariaDB Foundation provides a web wizard that allows us to do this by following very easy steps. This tool is available at the following URL:
https://downloads.mariadb.org/mariadb/repositories/
First, we must inform the tool about what we are using and what we want to install. The following screenshot shows the tool:
We will just need to follow four simple steps:
- Choose a Distro: Click on the name of the Linux distribution. For example: Mint.
- Choose a Release: Click on the name of the version of our Linux distribution. For example: Min 17 "Qiana".
- Choose a Version: Choose the MariaDB version that we want to install. For example: 10.0.
- Choose a Mirror: This is optional, because a mirror is already selected. However, we can choose a mirror that is closer to us, or another mirror if we find it slow.
At this point, in the lower part of the page, we can see the exact steps to be followed for setting up the specified official mirror in our system. The steps to install MariaDB may or may not be included. If they are not, we will follow one of the next sections, or our system's documentation.
The .deb packages
The .deb
packages are used in Debian GNU/Linux and in all the derived Linux distributions, including Ubuntu. These packages can be installed using apt-get
, aptitude, or the graphical package manager synaptic. These tools are generally preinstalled in the distributions derived from Debian.
We can install the mariadb-server
and mariadb-client
meta-packages to install the most recent stable MariaDB version that is available in the repository, including the command-line clients and tools. The following packages are optional but useful, and provide features that will be discussed in this book:
mariadb-connect-engine-10.0
: TheCONNECT
storage enginemariadb-oqgraph-engine-10.0
: TheOQGRAPH
storage engine
We can update the local list of packages, and then install MariaDB using apt-get using the following commands:
sudo apt-get update sudo apt-get upgrade sudo apt-get install mariadb-server mariadb-client mariadb-connect-engine-10.0 mariadb-oqgraph-engine-10.0
Note that this code snippet includes the optional packages mentioned previously.
The .rpm packages
The .rpm
packages are used in Linux distributions derived from Red Hat, including the community distribution Fedora, the enterprise-level CentOS, SuSE, and Mandriva. To manage these packages, we can use the YUM or up2date tools.
To install the latest version of the MariaDB server and client tools, we need to install the MariaDB-server and MariaDB-client, as follows:
sudo yum update sudo yum install MariaDB-server MariaDB-client
Installing MariaDB on Gentoo
Installing MariaDB on Gentoo Linux is very simple. We can use the emerge package to install the proper eBuild. The code is as follows:
emerge –sync emerge --ask mariadb
Only in cases where we want MariaDB to automatically start on system boot, can we run the following:
rc-update add mysql default
Generic Linux binaries
The MariaDB generic binaries can be useful for installing MariaDB on Linux distributions and other UNIX systems for which a specific package does not exist. Moreover, advanced users can modify the general installation procedure to customize the installation.
Users who install MariaDB from generic binaries for Linux/UNIX should be aware of two aspects:
- They will need to take care of the dependencies manually
- MariaDB updates will not be automatic
The following procedure should work on all Linux systems. If a problem occurs, we should check our system's documentation.
useradd -r mysql cd /usr/local tar zxvf /path/to/<package_name> ln -s <mariadb_dir> mysql cd mysql chown -R mysql . chgrp -R mysql . scripts/mysql_install_db --user=mysql chown -R root . chown -R mysql data
We will need to replace <package_name>
with the name of the file, and <mariadb_dir>
with the name of the file without the .tar.gz
extension.
Note that, with this procedure, we can install any number of MariaDB or MySQL versions. Each version will have its own subdirectory inside /usr/local
. A symbolic link called /usr/local/mysql
will point to the version of MariaDB/MySQL in use. Also note that, with this procedure, each installation will have its own data directory, which means that data will not be shared. The data directory should be configured in the my.cnf
file. You also need to configure a different port or Unix socket for each instance if you want to run them at the same time.
Installing on MacOS
The best way to install MariaDB on a MacOS X system is by using Homebrew. It is an unofficial, yet high-quality, open source package manager for MacOS. It is written in the Ruby language, and it requires Apple Xcode, which can be installed from the Apple Store.
So, if Homebrew is not installed on our system, first we need to install it. The following line usually does the trick:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
To make sure that the setup was successful, we may execute this command:
brew doctor
If we have problems, we can refer to the Homebrew online documentation at the following URL:
https://github.com/Homebrew/homebrew/wiki
With Homebrew properly installed, we need to update the packages list and install MariaDB. We can do this with commands that are similar to those supported by Debian's apt-get
:
brew update brew install mariadb