Before we can start using MariaDB, we have to install it. The MariaDB source code can be compiled to run on a wide variety of different platforms and system architectures, but there are pre-compiled packages available for Windows and Linux which make the process much easier.
There are several packages types, including the source code:
Windows MSI packages
Linux YUM packages
Linux APT packages
Linux and Windows binaries
Windows MSI packages are for computers and servers running Windows 8, Windows XP, and everything in between. Linux
.rpm packages are used on distributions, such as Fedora, CentOS, and Red Hat, which use the Yellow Dog Updater, Modified (YUM) package manager. Linux
.deb packages are used on distributions, such as Debian and Ubuntu, which use the Advanced Packaging Tool
(APT) package manager. We will cover how to install all these types in this chapter.
We will cover the fourth type, Linux and Windows Binaries, briefly. These packages are mainly useful to experienced users of MariaDB who have nonstandard setups. The Windows binaries come in a ZIP file (
.zip) and the Linux binaries in a gzipped tar file (
Even though MariaDB binaries are recommended for more experienced users, installing them is not especially difficult. Check the following links for the official instructions for installing the Linux and Windows binary packages, respectively:
We will also go over how to install MariaDB on Mac OS X. Packages for it are not supplied by the MariaDB developers, but by a third party.
The choice of which type of package to install is an easy one, just use whichever is appropriate for your system. If you are on Windows, use the MSI package. If you are on Ubuntu or Debian, use the APT packages. And if you are on Red Hat, Fedora, or CentOS, uses the YUM packages.
The next few sections contain instructions for each type, but before we get to that we need to talk about series. And no, it has nothing to do with baseball, but it does lend itself to a baseball analogy.
MariaDB development proceeds along multiple development tracks called series . There is a stable series and several maintenance series. Often, there is also a development series. This is similar to the Debian practice of having both a stable and unstable version.
The development series of MariaDB is where major new features and capabilities are introduced. Think of this like minor league baseball where the up and coming future stars are introduced and are polished and honed to perfection. At any given time, the quality of the current development release could range from Alpha (which has no guarantees that it will even work reliably) to Beta (which is feature complete but generally needs lots of bug fixing and testing) to Release Candidate (which is ready for general use except for some additional testing and minor bug fixing).
During the development cycle, there will generally be several alpha releases, where new features are introduced, followed by a couple beta releases where the code is refined and polished, followed by one or two RC releases where final fixes and polishing take place. The final step for any development series is when it is declared stable and moves into the major league stable series.
For most users just starting out, whatever series is marked stable is the one to use. This is the major league series. The best and most complete version currently available. After a development series has reached a sufficient level of quality to be considered stable, it is promoted to this series and becomes the recommended version of MariaDB.
After being marked as stable, the MariaDB Foundation has a policy that major MariaDB version will be well supported with bug and security fixes and maintenance releases for a period of at least five years. This is regardless of whether it is the current stable series, or if it is one of the maintenance series. It all depends on when it first became stable.
When a series moves from development to stable, whatever series was stable is moved to the maintenance series. This means that it will still receive bug fixes but it is no longer the recommended or preferred release of MariaDB. Think of it as the hall of fame—full of great previous releases of MariaDB that, while still excellent, have been replaced by a new generation. At any given time there may be three, four, or more MariaDB major versions in the maintenance series.
We'll now go through installing MariaDB for each of the major operating systems. First Windows, then Mac OS X, then Debian and Ubuntu Linux, then Fedora, Red Hat, and CentOS Linux, and lastly other Linux distributions.
There are two types of MariaDB downloads for Windows: ZIP files
and MSI packages. As mentioned previously, the ZIP files are similar to the Linux binary
.tar.gz files and they are only recommended for experts who know they want it. If we are starting out with MariaDB on Windows, it is recommended to use the MSI packages. Here are the steps to do just that:
Download the MSI package from https://downloads.mariadb.org/. First click on the series we want (stable, most likely), then locate the Windows 64-bit or Windows 32-bit MSI package. For most computers, the 64-bit MSI package is probably the one that we want, especially if we have more than 4 Gigabytes of RAM. If you're unsure, the 32-bit package will work on both 32-bit and 64-bit computers.
Once the download has finished, launch the MSI installer by double-clicking on it. Depending on our settings we may be prompted to launch it automatically. The installer will walk us through installing MariaDB.
Unless we need to, don't enable access from remote machines for the root user or create an anonymous account. We'll cover creating regular user accounts in Chapter 4, MariaDB User Account Management.
The Install as service box is checked by default, and it's recommended to keep it that way so that MariaDB starts up when the computer is booted. The Service Name textbox has the default value
MySQLfor compatibility reasons, but we can rename it if we like.
Check the Enable networking option, if you need to access the databases from a different computer. If we don't it's best to uncheck this box. As with the service name, there is a default TCP port number (3306) which you can change if you want to, but it is usually best to stick with the default unless there is a specific reason not to.
There are other settings that we can make through the installer. All of them can be changed later by editing the
my.inifile (more on that in Chapter 2, Configuring MariaDB), so we don't have to worry about setting them right away.
If our version of Windows has User Account Control enabled, there will be a pop-up during the installation asking if we want to allow the installer to install MariaDB. For obvious reasons, click on Yes.
After the installation completes, there will be a MariaDB folder added to the start menu. Under this will be various links, including one to the MySQL Client, which we will find out more about in Chapter 5, Using MariaDB).
Eventually we will be presented with a dialog box with an installation complete message and a Finish button. If you got this far, congratulations! MariaDB is now installed and running on your Windows-based computer. Click on Finish to quit the installer.
To learn about installing MariaDB on Mac OS X or Linux, read on. Otherwise, feel free to skip to the After the installation section at the end of this chapter.
One of the easiest ways to install MariaDB on Mac OS X is to use Homebrew, which is an Open Source package manager for that platform. Before you can install it, however, you need to prepare your system. The first thing you need to do is install Xcode; Apple's integrated development environment. It's available for free in the Mac App Store.
Once Xcode is installed you can install brew. Full instructions are available on the Brew Project website at http://mxcl.github.io/homebrew/ but the basic procedure is to open a terminal and run the following command:
ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)"
This command downloads the installer and runs it. Once the initial installation is completed, we run the following command to make sure everything is set up properly:
The output of the
doctor command will tell us of any potential issues along with suggestions for how to fix them. Once brew is working properly, you can install MariaDB with the following commands:
brew update brew install mariadb
Unlike on Linux and Windows, brew does not automatically set up or offer to set up MariaDB to start automatically when your system boots or start MariaDB after installation. To do so, we perform the following command:
ln -sfv /usr/local/opt/mariadb/*.plist ~/Library/LaunchAgents launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mariadb.plist
launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.mariadb.plist
To learn about installing MariaDB on Linux, read on. Otherwise, skip to the After the installation section at the end of this chapter.
This tool is used for APT-based Linux distributions such as Debian, Ubuntu, and Mint, YUM-based Linux distributions such as Fedora, CentOS, and Red Hat, and other distributions that have support for MariaDB built-in such as Mageia, Arch Linux, and openSUSE.
DISTRIB_ID=Ubuntu DISTRIB_RELEASE=10.04 DISTRIB_CODENAME=lucid DISTRIB_DESCRIPTION="Ubuntu 10.04.4 LTS"
The output shows that this machine is running Ubuntu 10.04 LTS "Lucid". So using the Repository Configuration Tool, click on Ubuntu, then 10.04 LTS 'lucid', then on the version or series of MariaDB you want to install. Lastly, click on the mirror you want to use. The tool will then output three pieces of text. The first are the commands to add the MariaDB repository to your system. The second contains the commands to install MariaDB, and the third contains the text and alternate instructions in case adding the repository using the first set of instructions did not work.
sudo apt-get install python-software-properties sudo apt-key adv --recv-keys \ --keyserver keyserver.ubuntu.com 0xcbcb082a1bb943db sudo add-apt-repository \ 'deb http://ftp.osuosl.org/pub/mariadb/repo/10.0/ubuntu precise main'
The first command installs the
python-software-properties package, which contains the helper command we will use. The second command installs the GPG key that is used to sign MariaDB packages. See the MariaDB package security section later in this chapter for more information on this. The third command adds the repository using the add-apt-repository command.
sudo apt-get update sudo apt-get install mariadb-server
mariadb-server package depends on the other MariaDB packages, so these two commands are all we need to install MariaDB. Once the second
apt-get command finishes, MariaDB will be installed and running. Congratulations!
The procedure for installing MariaDB on Fedora, Red Hat, and CentOS makes use of the Yellowdog Updater, Modified (YUM) package manager. There are two steps: first, create a
repo file for MariaDB and second, install MariaDB.
To generate the required text for the
repo file, we visit the MariaDB Repository Configuration Tool at: http://downloads.mariadb.org/mariadb/repositories/.
# MariaDB 10.0 CentOS repository list - created 2013-03-09 20:58 UTC # http://mariadb.org/mariadb/repositories/ [mariadb] name = MariaDB baseurl = http://yum.mariadb.org/10.0/centos6-amd64 gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB gpgcheck=1
gpgkey line tells YUM where the MariaDB signing key is located. The
gpgcheck line directs Yum to always use the signing key to verify the MariaDB packages. The first time we install MariaDB our system will not have the key so Yum will download it and install it. If Yum has never used the key before it will ask for confirmation whether it is OK to import the key. See the MariaDB package security section for more information on the MariaDB signing key.
Copy and paste the generated text from the repository configuration tool into a file using our favorite text editor. Naming the file something descriptive, such as MariaDB.repo, is recommended. Move the file to the
/etc/yum.repos.d/ folder using a command similar to the following:
sudo mv -vi MariaDB.repo /etc/yum.repos.d/
Once the file is in place, we are ready to install MariaDB. Installing MariaDB from the command line is as simple as:
sudo yum install MariaDB-server MariaDB-client
The capitalization of the package names is important. If we type
mariadb-server instead of
MariaDB-server, we'll get a package cannot be found error.
YUM will gather in all of the dependencies for MariaDB and present us with a list of things we need to install. If we are installing MariaDB on a new system, the list of packages YUM installs because of dependencies could be quite large. The following screenshot shows that there are more than 41 dependent packages that will be installed when we install MariaDB.
y, the installation will get going and we will be prompted to accept the GPG signing key. We verify the fingerprint with
y. Yum will then continue downloading and installing MariaDB and will end with a
sudo /etc/init.d/mysql start
[[email protected] ~]$ sudo /etc/init.d/mysql start Starting MySQL..... SUCCESS!
Jump ahead to the MariaDB package security section if you're interested in the MariaDB signing keys or skip to the After the installation section if you want to start using MariaDB right away.
MariaDB is also available on several other Linux distributions and even if no formal packages are provided the MariaDB developers provide generic Linux binaries that work with many versions of Linux. Instructions on how to install and use the generic binaries are available at https://mariadb.com/kb/en/installing-mariadb-binary-tarballs/.
Before installing the binary packages, however, it is worth our while to look in our distribution's package manager to see if MariaDB is already there. For example, Mageia, Arch Linux, openSUSE, and others all include MariaDB in their distributions' repositories. For those Linux distributions (including these three) that the MariaDB developers are familiar with, installation instructions are provided using the MariaDB repository configuration tool (https://downloads.mariadb.org/mariadb/repositories/).
The packages provided by the MariaDB developers are signed with a security key so that they can be verified by package managers such as Yum and Apt. The key signing and verification infrastructure on Linux is called Gnu Privacy Guard (GPG). It is a compatible Open Source version of Pretty Good Privacy (PGP) which is an industry standard data encryption, decryption, and verification system.
The identification number (GPG ID) of the MariaDB signing key is
0xcbcb082a1bb943db. For long-time users of GPG, this ID may seem a little long. That's because until recently, it was common to share a short form of the GPG ID. This is discouraged now because of a GPG's vulnerability; however many utilities will still display the short form by default. The long form of the ID is more secure, so this is what the MariaDB developers share when talking about the key. But, in case we want it, the short form of the ID is
1BB943DB (it's just the last eight characters of the long form ID). For the extra cautious, the full key fingerprint is:
1993 69E5 404B D5FC 7D2F E43B CBCB 082A 1BB9 43DB
The key IDs and fingerprint are also posted in the MariaDB Knowledgebase, which is the official location of the MariaDB documentation and is available at https://mariadb.com/kb/en/gpg/.
By checking the signature of the packages, Linux package managers, and more importantly, we, can verify whether the package that comes from the MariaDB developers and hasn't been tampered with since they created it.
When configuring the MariaDB repository on Debian and Ubuntu, and during the initial MariaDB install on Fedora, Red Hat, and CentOS, an important task is to import the signing key. It's a good idea to verify the key by comparing it to the IDs and the fingerprint when doing so. Thankfully, this is a one-time operation. Once the key is imported the process is fully automatic. We'll only be notified if the signature check fails.
After installing MariaDB, we can quickly test that MariaDB is up and running by opening a terminal or command-line window and running the following command (on Windows we can also open the mysql client .exe in the MariaDB folder):
mysql -u root -p
This command connects to MariaDB as the root user (
-u root) and prompts for the password of that user (
-p). When prompted, type in the password configured during the install. If no password was set during the install, remove
-p. Until a password is set we can connect without a password.
Not having a password for the root user can be dangerous! If you did not set one during the installation, be sure to set one immediately after the install following the instructions in Chapter 3, MariaDB Security.
If MariaDB has been successfully installed and started, we should see something similar to the following screenshot when connecting using the previous command to launch the
mysql command-line client:
If you get the MariaDB command-line prompt as illustrated in the preceding screenshot, congratulations! You've just installed MariaDB and can successfully connect to the server using the command-line client. You can quit the command-line client for now. Don't worry; we'll come back to it soon.
The MariaDB installers work very well. And they are tested and retested constantly. Occasionally issues with either installing MariaDB or running it for the first time are discovered, but they are almost always fixed promptly so that users are not affected.
If we do happen to run into an issue when trying to start MariaDB, what should we do?
The first thing we should do is look in the error log. The MariaDB error log is either stored with the system logfiles (for example, under
/var/log/ on Linux) or in the MariaDB data directory. Common locations for the MariaDB data directory include
/var/lib/mysql/ on Linux,
C:\Program Files\MariaDB <version>\data\ on Windows (
<version> is the version number of MariaDB we are using), and
/usr/local/var/mysql/ on Mac OS X. The error logfile itself will either be called
hostname.err where hostname is the name we've given our computer. It is also worth noting that the name and location of the logfile can be customized by the
my.ini file. The next chapter on configuring MariaDB will go into this file and its location.
Each entry inside the error logfile consists of a timestamp and a description of what went wrong at that timestamp. Sometimes the information given is enough for us to figure it out ourselves, but sometimes we may need to ask for help. We shouldn't feel bad if we can't figure an error out, even experts are sometimes stumped! If we do need to ask for help, the resources listed on the following page, especially the Maria Discuss mailing list and the official IRC channel can help greatly: https://mariadb.com/kb/en/where-are-other-users-and-developers-of-mariadb/