On the centos 7.3 interactive interface, install mariadb10.2.8 in binary mode,

Source: Internet
Author: User
Tags mysql create

On the centos 7.3 interactive interface, install mariadb10.2.8 in binary mode,
Mariadb Introduction

The MariaDB database management system is a branch of MySQL and is mainly maintained by the open-source community. The purpose of using GPL to authorize MariaDB is to be fully compatible with MySQL, including APIs and command lines, it can easily become a substitute for MySQL. In terms of storage engine, XtraDB is used to replace InnoDB of MySQL. MariaDB was developed by Michael Widenius, MySQL founder. He sold his own company MySQL AB to SUN for $1 billion, as SUN was acquired by Oracle, the ownership of MySQL also fell into the hands of Oracle. MariaDB is named by Michael Widenius's daughter Maria.
From https://baike.baidu.com/item/mariaDB/6466119? Fr = aladdin for details, Baidu

Experiment: Install mariadb10.2.8 in binary mode on the centos 7.3 interactive interface

1. Check whether mariadb has been installed on the local machine. If mariadb has been installed, stop the service first.
Rpm-qa mariadb *

2. Prepare the user
Getent passwd mysql check whether the mysql user has created
Useradd-d/app/mysqldb-r-m-s/sbin/nologin mysql if not created, follow this command to create

3. Prepare the data directory
Take/app/mysqldb as an example. We recommend that you use logical volumes.
Chown mysql: mysql/app/mysqldb

4. Prepare a binary Program
Tar xvf mariadb-10.2.8-linux-x86_64.tar.gz-C/usr/local/must be decompressed to the/usr/local/directory
Cd/usr/local/
Ln-s mariadb-10.2.8-linux-x86_64/mysql CREATE soft link

5. Prepare the configuration file
Cd/usr/local/mysql/
Mkdir/etc/mysql/
Cp support-files/my-huge.cnf/etc/mysql/my. cnf
Vim/etc/mysql/my. cnf

[Mysqld] datadir =/app/mysqldb must be added to the innodb_file_per_table = on database engine. Each form has a unique file, which is not required, to facilitate the management of skip_name_resolve = on, ignore name resolution and speed up access, this line is not required

6. Create a database file
Cd/usr/local/mysql/
Scripts/mysql_install_db-user = mysql-datadir =/app/mysqldb do not enter the scripts directory to run the script. An error is reported and must be run in the/usr/local/mysql directory.

7. Create a log directory and enable the mysql user to be the owner of the log directory.
Mkdir/var/log/mariadb/
Chown mysql/var/log/mariadb/

8. Add/usr/local/mysql/bin to the Environment path.
Vi/etc/profile. d/mysql. sh
PATH =/usr/local/mysql/bin: $ PATH
./Etc/profile. d/mysql. sh

9 prepare the Service Startup Script and start the service
Cp support-files/mysql. server/etc/init. d/mysqld
Chkconfig-add mysqld
Chkconfig-list mysqld
Service mysqld start service

10 Security Initialization
Mysql_secure_installation

11. log on to the database and test whether the installation is successful.
Mysql-uroot-p

Experiment: Install mariadb 5.5.57 in binary mode on the centos 6.9 interactive interface

[-D/app] | mkdir/app
Useradd-d/app/mysqldb-r-m-s/sbin/nologin mysql
Tar xf/root/mariadb-5.5.57-linux-x86_64.tar.gz-C/usr/local/
Ln-s/usr/local/mariadb-5.5.57-linux-x86_64/usr/local/mysql
Cd/usr/local/mysql/
Mkdir/etc/mysql/
Cp support-files/my-huge.cnf/etc/mysql/my. cnf
Vim/etc/mysql/my. cnf
[Mysqld]
Datadir =/app/mysqldb
Innodb_file_per_table = on
Skip_name_resolve = on

Scripts/mysql_install_db-user = mysql-datadir =/app/mysqldb &>/dev/null
Cp support-files/mysql. server/etc/init. d/mysqld
Chkconfig-add mysqld
Touch/var/log/mysqld. log
Chown mysql/var/log/mysqld. log
Echo 'path =/usr/local/mysql/bin: $ path'>/etc/profile. d/mysql. sh
Service mysqld start

Experiment: use scripts to automatically determine the OS version and install mariadb

Requirement: mariadb 5.5.57 is installed in centOS6 and mariadb10.2.8 is installed in centOS.

#! /Bin/bash # ------------------------------------------------- # Filename: mysqld-binary-install.sh # Revision: 1.0 # Date: 2017-10-20 # Author: Ruoshuiss # Website: https://blog.csdn.net/ruoshuiss/# Description: Binary installation of the mariadb script # ------------------------------------------------- ver = 'sed-r's /. * ([0-9] + )\.. */\ 1/'/etc/centos-release' # judge the OS version [-d/app] | mkdir/app getent passwd mysql &>/dev/null | {userdel-r mysql &>/dev/null; useradd-d/app/mysqldb-r-m-s/sbin/nologin mysql;} if [$ ver-eq 6]; then # if centOS6 is used, perform the following operations tar xf/root/mariadb-5.5.57-linux-x86_6 4.tar.gz-C/usr/local/ln-s/usr/local/mariadb-5.5.57-linux-x86_64/usr/local/mysql touch/var/log/mysqld. log chown mysql/var/log/mysqld. logelif [$ ver-eq 7]; then # If it is centOS7, perform the following operations tar xf/root/mariadb-10.2.8-linux-x86_64.tar.gz-C/usr/local/ln-s/usr/local/mariadb-10.2.8-linux-x86_64 // usr/local/mysql mkdir/var/log/mariadb /chown mysql/var/log/mariadb/else # exit if it is neither centOS6 nor centOS7 Script echo "this OS over range! & Quot; exitficd/usr/local/mysql/mkdir/etc/mysql/cp support-files/my-huge.cnf/etc/mysql/my. cnfsed-I's # ^ \ [mysqld \] # & \ ndatadir =/app/mysqldb \ ninnodb_file_per_table = on \ nskip_name_resolve = on # G'/etc/mysql/my. cnf # Use sed to modify the configuration file scripts/mysql_install_db -- user = mysql -- datadir =/app/mysqldb &>/dev/nullcp support-files/mysql. server/etc/init. d/mysqldchkconfig -- add mysqldecho 'path =/usr/local/mysql/bin: $ path'>/etc/profile. d/mysql. shservice mysqld start

Related Article

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.