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
Http://mirrors.scie.in/mariadb/mariadb-5.5.33a/kvm-tarbake-jaunty-x86/mariadb-5.5.33a.tar.gz
2. Download cmake (MariaDB compilation tool)
Http://www.cmake.org/files/v2.8/cmake-2.8.12.1.tar.gz
Download the above two software and upload it to the/usr/local/src directory.
System O & M www.osyunwei.com reminder: qihang01 original content is copyrighted. For more information, see the source and original article links.
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:
System O & M www.osyunwei.com reminder: qihang01 original content is copyrighted. For more information, see the source and original article links.
At this point, MariaDB database installation is complete!