Installing and Configuring MariaDB 10 on CentOS 6

0
Want create site? Find Free WordPress Themes and plugins.
This tutorial will guide you through the deployment process of MariaDB on a Red Hat-based Linux server, such as CentOS. We’ll start by configuring the hardware and then move into the installation and configuration of MariaDB.MariaDB is a fork of the very popular and open source MySQL database, which is now owned by Oracle. In fact, the two were created by the same individual. They are essentially a mirror of each other, so a lot of the knowledge used to run MySQL can be used for MariaDB. This should make migration easier to swallow.

Install MariaDB

Add the MariaDB Repository

We can add the repository to our server to make installing the database service a lot easier – plus we’ll ensure patches are more easily accessible.

  1. Navigate to /etc/yum.repos.d/ on your CentOS box.
  2. Create a new file called MariaDB.repo.
  3. For 64-bit installs of CentOS, add the following lines.
    [mariadb]
    name = MariaDB
    baseurl = http://yum.mariadb.org/10.0/centos6-amd64
    gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
    gpgcheck=1
  4. For 32-bit installs of CentOS, add the following lines.
    [mariadb]
    name = MariaDB
    baseurl = http://yum.mariadb.org/10.0/centos6-x86
    gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
    gpgcheck=1
  5. Install the required packages onto your server.
    yum install MariaDB-server MariaDB-client

Configuring MariaDB

The configuration files and binaries for MariaDB are mostly the same as MySQL. For example, both use a configuration file called my.cnf. Even the daemon binary is called mysql. This is done done to ensure people can more easily migrate from MySQL. The default configuration file is too liberal. It should not be used in either testing or production. If you are just playing around and learning the software, however, it should be fine. The MariaDB installation includes several  configuration file templates that can be used to quickly configure the server. The one you choose depends on how large you expect your databases to get.

  1. Backup the original configuration file by renaming it.
mv /etc/my.cnf /etc/my.bak
  • Create a new my.cnf file by copying an existing template. We’ll use the medium server template for this example.
    cp /usr/share/mysql/my-medium.cnf /etc/my.cnf
  • Start the MariaDB service (daemon).
    service mysql start
  • Configure MariaDB to start automatically when the system is booted.
    chkconfig mysql on

Securing the Installation

The default installation includes settings and accounts that are good for testing, but they will make your server a fairly large security target. One example is the Root database account – it has no set password. Anyone can access your databases just knowing this account name. Thankfully, much like MySQL, we can run a script that walks us through closing these security concerns.

  1. Run the secure installation script. MariaDB must be running before this script can be executed.
/usr/bin/mysql_secure_installation
  • You are prompted to enter the password for root. Since none exists, you can press Enter to continue.
  • A prompt to change the password for root will appear. Press ‘Y’ and then Enter to set one.
  • Next you will be prompted to remove anonymous users. Press ‘Y’ and then Enter to do so,
  • When asked to disallow root remote login, press ‘Y’ and then Enter. Your root account should never have remote access.
  • When prompted to remove the test database, press ‘Y’ and then Enter.
  • Finally, you will be asked to reload the privileges table. Press ‘Y’ and then Enter. This will flush out the old permissions to apply the new ones.

Logging into MariaDB

The administer the server and create databases we need to log in. To do this we use the following command.

mysql -u  -p

The -u switch tells MariaDB which user account to log in with, and the -p switch tells it to prompt us for a password. To log in as root, we would do the following.

mysql -u root -p

Did you find apk for android? You can find new Free Android Games and apps.

You might also like More from author