How to compile and install the MariaDB database in Linux

Source: Internet
Author: User
This article describes how to compile and install the MariaDB database in Linux. For more information, see.

This article describes how to compile and install the MariaDB database in Linux. For more information, see.

This article describes how to compile and install the MariaDB database in Linux. For more information, see.

Note:

Operating System: CentOS 5.10 32-bit
MariaDB: mariadb-5.5.33a
MariaDB database storage directory:/data/mysql

Preparation:

1. Configure the IP address, DNS, and gateway to ensure that the remote connection tool can be used to connect to the server. The yum command on the server can be used normally.

2. configure the firewall and enable port 3306
Vi/etc/sysconfig/iptables # Edit
-A RH-Firewall-1-INPUT-m state -- state NEW-m tcp-p tcp -- dport 3306-j ACCEPT # Allow port 3306 through the firewall

Note: many users add these two rules to the last line of the firewall configuration, which causes firewall startup failure. The correct rule should be added to the default port 22.

The firewall rules are as follows:

**************************************** **************************************** **
# Firewall configuration written by system-config-securitylevel
# Manual customization of this file is not recommended.
* Filter
: Input accept [0: 0]
: Forward accept [0: 0]
: Output accept [0: 0]
: RH-Firewall-1-INPUT-[0: 0]
-A input-j RH-Firewall-1-INPUT
-A forward-j RH-Firewall-1-INPUT
-A RH-Firewall-1-INPUT-I lo-j ACCEPT
-A RH-Firewall-1-INPUT-p icmp -- icmp-type any-j ACCEPT
-An RH-Firewall-1-INPUT-p 50-j ACCEPT
-An RH-Firewall-1-INPUT-p 51-j ACCEPT
-A RH-Firewall-1-INPUT-p udp -- dport 5353-d 224.0.0.20.- j ACCEPT
-A RH-Firewall-1-INPUT-p udp-m udp -- dport 631-j ACCEPT
-A RH-Firewall-1-INPUT-p tcp-m tcp -- dport 631-j ACCEPT
-A RH-Firewall-1-INPUT-m state -- state ESTABLISHED, RELATED-j ACCEPT
-A RH-Firewall-1-INPUT-m state -- state NEW-m tcp-p tcp -- dport 22-j ACCEPT
-A RH-Firewall-1-INPUT-m state -- state NEW-m tcp-p tcp -- dport 3306-j ACCEPT
-A RH-Firewall-1-INPUT-j REJECT -- reject-with icmp-host-prohibited
COMMIT
**************************************** **************************************** **

/Etc/init. d/iptables restart # restart the firewall to make the configuration take effect.

3. Disable SELINUX

Vi/etc/selinux/config
# SELINUX = enforcing # comment out
# SELINUXTYPE = targeted # comment out
SELINUX = disabled # Add
: Wq! # Save and exit
Shutdown-r now # restart the system

Iv. system conventions

Location of MariaDB installation package:/usr/local/src
MariaDB compilation and installation location:/usr/local/mysql

5. download the software package

1. Download MariaDB

2. Download cmake (MariaDB compilation tool)

Download the above two software and upload it to the/usr/local/src directory.

6. Install the compilation tool and library files (use the CentOS yum command to install and install php and nginx in the future)

Yum install make apr * autoconf automake curl-devel gcc-c ++ gtk +-devel zlib-devel openssl-devel pcre-devel gd kernel keyutils patch perl kernel-headers compat * cpp glibc libgomp libstdc ++-devel keyutils-libs-devel libsepol-devel license-devel krb5-devel libXpm * freetype-devel freetype * fontconfig-devel lib* libpng * php-common php-gd gettext-devel ncurses * libtool * libxml2 libxml2-devel patch policycoreutils bison

Installation

1. Install cmake
Cd/usr/local/src
Tar zxvf cmake-2.8.12.1.tar.gz
Cd cmake-2.8.12.1
./Configure
Make # compile
Make install # install

Ii. Install MariaDB

Groupadd mysql # Add MariaDB database installation user group mysql
Useradd-g mysql-s/bin/false # create a user mysql and add it to the mysql group. mysql users are not allowed to log on directly to the system.
Mkdir-p/data/mysql # create the MariaDB database storage directory
Chown-R mysql: mysql/data/mysql # Set the directory permission of the MariaDB Database
Mkdir-p/usr/local/mysql # create the MariaDB installation directory
Cd/usr/local/src
Tar zxvf mariadb-5.5.33a.tar.gz # Extract
Cd mariadb-5.5.33a # enter the installation directory
Cmake.-DCMAKE_INSTALL_PREFIX =/usr/local/mysql-DMYSQL_DATADIR =/data/mysql-DSYSCONFDIR =/etc
# Configuration
Make # compile
Make install # install
Cd/usr/local/mysql
Cp./support-files/my-huge.cnf/etc/my. cnf # copy the configuration file (Note: if there is a my. cnf under the/etc directory by default, directly overwrite it)
Vi/etc/my. cnf # edit the configuration file and add it in [mysqld ].
Datadir =/data/mysql # Add the MariaDB database path
./Scripts/mysql_install_db -- user = mysql # generate the MariaDB System Database
Cp./support-files/mysql. server/etc/rc. d/init. d/mysqld # Add MariaDB to system startup
Chmod 755/etc/init. d/mysqld # Add execution permission
Chkconfig mysqld on # Add to startup
Vi/etc/rc. d/init. d/mysqld # Edit
Basedir =/usr/local/mysql # MariaDB installation path
Datadir =/data/mysql # MariaDB database storage directory
Service mysqld start # start
Vi/etc/profile # Add the MariaDB service to the system environment variable: Add the following line at the end
Export PATH = $ PATH:/usr/local/mysql/bin
The following two lines link the MariaDB library file to the default system location, so that you do not need to specify the MariaDB library file address when compiling software such as PHP.
Ln-s/usr/local/mysql/lib/mysql/usr/lib/mysql
Ln-s/usr/local/mysql/include/mysql/usr/include/mysql
Shutdown-r now # restart the system. Wait until the system is restarted and continue to perform the following operations on the terminal command line.
Mysql_secure_installation # Set the password of the root account of the MariaDB Database
Press Y to enter the password twice as prompted.
Or directly change the password/usr/local/mysql/bin/mysqladmin-u root-p password "123456" # change the password
Service mysqld restart # restart
Mysql-u root-p # enter the above root password to log on to the mariadb console, as shown in:

At this point, MariaDB database installation is complete!

Install LAMP (Apache with MariaDB and PHP) in CentOS/RHEL/Scientific Linux 6)

Implementation of MariaDB Proxy read/write splitting

MariaDB details: click here
MariaDB's: click here

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.