{"id":6497,"date":"2017-02-27T08:59:19","date_gmt":"2017-02-27T00:59:19","guid":{"rendered":"http:\/\/rmohan.com\/?p=6497"},"modified":"2017-02-27T08:59:19","modified_gmt":"2017-02-27T00:59:19","slug":"installing-and-configuring-mariadb-10-on-centos-6","status":"publish","type":"post","link":"https:\/\/mohan.sg\/?p=6497","title":{"rendered":"Installing and Configuring MariaDB 10 on CentOS 6"},"content":{"rendered":"<section>This tutorial will guide you through the deployment process of MariaDB on a Red Hat-based Linux server, such as CentOS. We\u2019ll start by configuring the hardware and then move into the installation and configuration of MariaDB.<\/p>\n<p>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.<\/p>\n<h2>Install MariaDB<\/h2>\n<h3>Add the MariaDB Repository<\/h3>\n<p>We can add the repository to our server to make installing the database service a lot easier \u2013 plus we\u2019ll ensure patches are more easily accessible.<\/p>\n<ol>\n<li>Navigate to <strong>\/etc\/yum.repos.d\/<\/strong> on your CentOS box.<\/li>\n<li>Create a new file called <strong>MariaDB.repo<\/strong>.<\/li>\n<li>For 64-bit installs of CentOS, add the following lines.\n<div class=\"line\">[mariadb]<\/div>\n<div class=\"line\">\u00a0name = MariaDB<\/div>\n<div class=\"line\">\u00a0baseurl = http:\/\/yum.mariadb.org\/10.0\/centos6-amd64<\/div>\n<div class=\"line\">\u00a0gpgkey=https:\/\/yum.mariadb.org\/RPM-GPG-KEY-MariaDB<\/div>\n<div class=\"line\">\u00a0gpgcheck=1<\/div>\n<\/li>\n<li>For 32-bit installs of CentOS, add the following lines.\n<div class=\"line\">[mariadb]<\/div>\n<div class=\"line\">\u00a0name = MariaDB<\/div>\n<div class=\"line\">\u00a0baseurl = http:\/\/yum.mariadb.org\/10.0\/centos6-x86<\/div>\n<div class=\"line\">\u00a0gpgkey=https:\/\/yum.mariadb.org\/RPM-GPG-KEY-MariaDB<\/div>\n<div class=\"line\">\u00a0gpgcheck=1<\/div>\n<\/li>\n<li>Install the required packages onto your server.\n<pre class=\"bash\">yum install MariaDB-server MariaDB-client<\/pre>\n<\/li>\n<\/ol>\n<\/section>\n<section>\n<h2>Configuring MariaDB<\/h2>\n<p>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.<\/p>\n<p>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.<\/p>\n<p>The MariaDB installation includes several \u00a0configuration 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.<\/p>\n<table class=\"list\">\n<tbody>\n<tr>\n<th width=\"20%\">my-small.cnf<\/th>\n<td>Ideal for servers with a very limited amount RAM (64MB or less)\u00a0available for your databases. An example would be a small LAMP server hosting all web-related roles.<\/td>\n<\/tr>\n<tr>\n<th>my-medium.cnf<\/th>\n<td>Ideal for dedicated database servers with 128MB of available memory or less. Another good example for multi-role servers.<\/td>\n<\/tr>\n<tr>\n<th>my-large.cnf<\/th>\n<td>Ideal for\u00a0for servers with at least 512MB of RAM available for the database server.<\/td>\n<\/tr>\n<tr>\n<th>my-huge.cnf<\/th>\n<td>Ideal for servers with 1GB of RAM or more available to the database server.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n<ol>\n<li>Backup the original configuration file by renaming it.\n<pre class=\"bash\">mv \/etc\/my.cnf \/etc\/my.bak<\/pre>\n<\/li>\n<li>Create a new my.cnf file by copying an existing template. We\u2019ll use the medium server template for this example.\n<pre class=\"bash\">cp \/usr\/share\/mysql\/my-medium.cnf \/etc\/my.cnf<\/pre>\n<\/li>\n<li>Start the MariaDB service (daemon).\n<pre class=\"bash\">service mysql start<\/pre>\n<div class=\"notice-info\">That is not a typo. MariaDB\u2019s service name is mysql.<\/div>\n<\/li>\n<li>Configure MariaDB to start automatically when the system is booted.\n<pre class=\"bash\">chkconfig mysql on<\/pre>\n<\/li>\n<\/ol>\n<h2>Securing the Installation<\/h2>\n<p>The default installation includes settings and accounts that are good for testing, but they will make your server a fairly large security target.<\/p>\n<p>One example is the Root database account\u00a0\u2013 it has no set password. Anyone can access your databases just knowing this account name.\u00a0Thankfully, much like MySQL, we can run a script that walks us through closing these security concerns.<\/p>\n<ol>\n<li>Run the secure installation script. MariaDB must be running before this script can be executed.\n<pre class=\"bash\">\/usr\/bin\/mysql_secure_installation<\/pre>\n<\/li>\n<li>You are prompted to enter the password for root. Since none exists, you can press Enter to continue.<\/li>\n<li>A prompt to change the password for root will appear. Press \u2018Y\u2019 and then Enter to set one.<\/li>\n<li>Next you will be prompted to remove anonymous users. Press \u2018Y\u2019 and then Enter to do so,<\/li>\n<li>When asked to disallow root remote login, press \u2018Y\u2019 and then Enter. Your root account should never have remote access.<\/li>\n<li>When prompted to remove the test database, press \u2018Y\u2019 and then Enter.<\/li>\n<li>Finally, you will be asked to reload the privileges table. Press \u2018Y\u2019 and then Enter. This will flush out the old permissions to apply the new ones.<\/li>\n<\/ol>\n<h3>Logging into MariaDB<\/h3>\n<p>The administer the server and create databases we need to log in. To do this we use the following command.<br \/>\n<code class=\"syntax\">mysql -u &lt;username&gt; -p<\/code><br \/>\nThe <strong>-u<\/strong> switch tells MariaDB which user account to log in with, and the <strong>-p<\/strong> switch tells it to prompt us for a password. To log in as root, we would do the following.<\/p>\n<pre class=\"bash\">mysql -u root -p<\/pre>\n<\/section>\n","protected":false},"excerpt":{"rendered":"<p>This tutorial will guide you through the deployment process of MariaDB on a Red Hat-based Linux server, such as CentOS. We\u2019ll start by configuring the hardware and then move into the installation and configuration of MariaDB.<\/p>\n<p>MariaDB is a fork of the very popular and open source MySQL database, which is now owned by Oracle. [&#8230;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[72],"tags":[],"_links":{"self":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/6497"}],"collection":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=6497"}],"version-history":[{"count":1,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/6497\/revisions"}],"predecessor-version":[{"id":6498,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/6497\/revisions\/6498"}],"wp:attachment":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=6497"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=6497"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=6497"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}