Chapter 2. Configuring MariaDB

MariaDB is installed with a generic configuration that is suitable for general use. This is perfect for giving MariaDB a try but might not be suitable for a production database application under a heavy load. There are thousands of ways to tweak the settings to get MariaDB to perform just the way we need it to. Many books have been written on this subject. In this chapter, we'll cover enough of the basics so that we can comfortably edit the MariaDB configuration files and know our way around. Think of this chapter as a MariaDB configuration highlights tour.

The topics that we will cover in this chapter include the following:

  • The MariaDB filesystem layout
  • Modular configuration on Linux
  • The anatomy of the MariaDB configuration file
  • Activating configuration changes

The MariaDB filesystem layout

A MariaDB installation is not a single file or even a single directory, so the first stop on our tour is a high-level overview of the filesystem layout. We'll start with Windows and then move on to Linux.

The MariaDB filesystem layout on Windows

On Windows, MariaDB is installed under a directory named with the following pattern:

C:Program FilesMariaDB <major>.<minor>

In the preceding command, <major> and <minor> refer to the first and second number in the MariaDB version string. So for MariaDB 10.1, the location would be:

C:Program FilesMariaDB 10.1

The only alteration to this location, unless we change it during the installation, is when the 32-bit version of MariaDB is installed on a 64-bit version of Windows. In that case, the default MariaDB directory is at the following location:

C:Program Files x86MariaDB <major>.<minor>

Under the MariaDB directory on Windows, there are four primary directories: bin, data, lib, and include. There are also several configuration examples and other files under the MariaDB directory and a couple of additional directories (docs and Share), but we won't go into their details here.

The bin directory is where the executable files of MariaDB are located.

The data directory is where databases are stored; it is also where the primary MariaDB configuration file, my.ini, is stored. We'll talk about this file later in the section The anatomy of the MariaDB configuration file.

The lib directory contains various library and plugin files.

Lastly, the include directory contains files that are useful for application developers.

We don't generally need to worry about the bin, lib, and include directories; it's enough for us to be aware that they exist and know what they contain. The data directory is where we'll spend most of our time in this chapter, and when using MariaDB.

Feel free to read the next two sections, which explain the location of MariaDB files on Linux systems, or jump ahead to the section The anatomy of the MariaDB configuration file.

The MariaDB filesystem layout on Linux

On Linux distributions, MariaDB follows the default filesystem layout. Feel free to skip this section if you are working with Windows.

For example, the MariaDB binaries are placed under /usr/bin/, libraries are placed under /usr/lib/, manual pages are placed under /usr/share/man/, and so on.

However, there are some key MariaDB-specific directories and file locations that we should know about. Two of them are locations that are the same across most Linux distributions. These locations are the /usr/share/mysql/ and /var/lib/mysql/ directories.

The /usr/share/mysql/ directory contains helper scripts that are used during the initial installation of MariaDB, translations (so we can have error and system messages in different languages), and character set information. We don't need to worry about these files and scripts; it's enough to know that this directory exists and contains important files.

The /var/lib/mysql/ directory is the default location for our actual database data and the related files such as logs. There is not much need to worry about this directory as MariaDB will handle its contents automatically; for now, it's enough to know that it exists.

The next directory we should know about is the one where the MariaDB plugins are stored. Unlike the previous two, the location of this directory varies. On Debian and Ubuntu systems, this directory is at the following location:

/usr/lib/mysql/plugin/

In distributions such as Fedora, Red Hat, and CentOS, the location of the plugin directory varies depending on whether our system is 32 bit or 64 bit. If unsure, we can just look in both. The possible locations are:

/lib64/mysql/plugin/
/lib/mysql/plugin/

The basic rule of thumb is that if we don't have a /lib64/ directory, we have a 32-bit version of Fedora, Red Hat, or CentOS installed.

As with /usr/share/mysql/, we don't need to worry about the contents of the MariaDB plugin directory. It's enough to know that it exists and contains important files. Also, if in the future we install a new MariaDB plugin, this directory is where it will go.

The last directory that we should know about is only found on Debian and the distributions based on Debian such as Ubuntu. Its location is as follows:

/etc/mysql/

The /etc/mysql/ directory is where the configuration information for MariaDB is stored; specifically, it is stored in the following two locations:

/etc/mysql/my.cnf
/etc/mysql/conf.d/

There are additional files in the directory, but we can safely ignore them for now. We'll look into the contents of the my.cnf file in the section The anatomy of the MariaDB configuration file, and we'll talk about the special /etc/mysql/conf.d/ directory in the Modular configuration on Linux section.

Fedora, Red Hat, CentOS, and related systems don't have an /etc/mysql/ directory by default, but they do have a my.cnf file and a directory that serves the same purpose that the /etc/mysql/conf.d/ directory does on Debian and Ubuntu. They are at the following two locations:

/etc/my.cnf
/etc/my.cnf.d/

The my.cnf files, regardless of location, function the same on all Linux versions and on Windows, where it is often named my.ini. The /etc/my.cnf.d/ and /etc/mysql/conf.d/ directories, as mentioned, serve the same purpose. We'll spend the next section going over these two directories.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.139.82.4