Universal binary installation MySQL (MariaDB)

Source: Internet
Author: User
Tags mysql in parent directory

First, preface

MySQL is a relational database management system, is the most popular relational database management system, because of its small size, fast, low total cost of ownership, and was completely open source, so popular. But since MySQL was sold to Sun, then Sun was acquired by Oracle, and although there is also a free version of open source, many features require a separate commercial version, resulting in a gradual decrease in MySQL usage today. So Mariadb was born for this reason, become a database management system is a branch of MySQL.



Ii. introduction of MARIADB

MARIADB database management System is a branch of MySQL, mainly by the open source community in the maintenance, the use of GPL licensing MARIADB is fully compatible with MySQL. The transaction-based Maria storage engine replaces MySQL's MyISAM storage engine. Although MARIADB is seen as a replacement for MySQL databases, it is stronger than MySQL in terms of extensions, storage engines, and some new improvements in functionality. and migrating from MySQL to mariadb is also very simple.

Tips:www.mariadb.org is the official site



Three, MariaDB installation Introduction

3.1, need to pay attention to the place before installation

for a generic binary format package, we only need to extract and then use, but because the binary format of the package is a compiled binary, so there are some scripts in the fixed path to execute some scripts, so they require MySQL this path must be installed in/usr Under the/local directory (similar to a third-party program Path), and the directory name of its directory must be called MySQL. Because if you do not do this, many of the default scripts will not run.  

3.2. MARIADB generic binary Package after decompression file description

Bin: Various binaries are in this directory data: If we do not create a new directory, this directory is the default data directory. So permissions must be both the owner and the group are Mysqldocs: Related documents include: Header file Lib: library file man: Help manual Mysql-test:mysql test Group Scripts:mysql Share:mysql shared content of the script to be used when initializing Sql-bench: Do a stress test tool for MySQL support-files:mysql the normal running sample configuration file or Document

3.2, MARIADB official installation instructions introduced

     tips: in-pass There is a Setup help message called "Install-binary" in the binary package, so you can check this file information before installing. The explanations of the help information mentioned in the following are described below. However, the installation steps may not be exactly the same as the installation Help information, so the official installation help is for reference only.

[[email protected] mysql]# less install-binary      #解压后, you can use this command to view, Locate the following field. shell> groupadd mysql               #添加一个组名shell > useradd -g mysql mysql      #添加一个用户shell > cd /usr/local                #进去/usr/local directory under Shell> gunzip < /path/to/mysql-version-os.tar.gz | tar  xvf -     #把通用二进制MariaDB进行解压到此目录shell > ln -s  full-path-to-mysql-version-os mysql       #链接目录到到目录名为mysql的目录名 ( The directory name mentioned above must be called MySQL) shell> cd mysql shell> chown -r mysql .            #把mysql路径下所有文件的属主改为mysqlshell > chgrp -r  mysql .           #属组改为mysqlshell > scripts/mysql_install_db --user=mysql      #执行此脚本完成以mysql的身份完成mysql数据初始化shell > chown -R root .             #然后在把它的的权限改为rootshell > chown -R mysql data         #但是把这个目录下的data属主改回mysqlshell > bin/mysqld_safe --user=mysql  &     #而后使用此命令即可启动mysql

3.3. Other areas needing attention

Considering the installation of this method, the database file will be stored in the directory data file by default, but if the enterprise data will grow rapidly, resulting in a large database file, the security and scalability is not good, so the enterprise generally stored on another disk will be more secure. In order to use the specification later, it is recommended that the data catalog be planned in advance and assigned in a unique location, such as finding a disk to hold MySQL data.



Iv. installation of mariadb-5.5.36

4.1. Download MARIADB Package

MARIADB official site Download the mariadb-5.5.36-linux-x86_64.tar.gz package and copy it to the Linux server.

4.2. Extracting files to/usr/local path

Must be extracted to this path for reasons previously described

[Email protected] local]# tar XF mariadb-5.5.36-linux-x86_64.tar.gz-c/usr/local/

4.3, modify directory name (here is linked to directory named MySQL directory)

[[email protected] local]# ln-s mariadb-5.5.36-linux-x86_64 MySQL

here's how to create a link with a name named MySQL because if you need to upgrade later in the future Maridb Again, remove the original version and rename the new MySQL , it will be more troublesome

4.4. Create MySQL users and groups

[[email protected] local]# groupadd-r mysql[[email protected] local]# useradd-g mysql-r MySQL

4.5. Modify the permissions of the MySQL folders

See the following permissions under MySQL files

650) this.width=650; "src=" Http://www.178linux.com/ueditor/php/upload/image/20151014/1444837950710465.jpg "title= "1444837950710465.jpg" alt= "1.jpg"/>

Modify Permissions

[Email protected] mysql]# chown-r root.mysql./*

Modify permissions for the data directory

[Email protected] mysql]# chown-r mysql.mysql./data

4.6. Pre-initialize MySQL preparation

Because MySQL requires some configuration files during initialization, there are a lot of sample configuration files available in Support-file. Among them are: MY-HUGE.CNF,MY-INNODB-HEAVY-4G.CNF,MY-LARGE.CNF,MY-MEDIUM.CNF,MY-SMALL.CNF. These are different profiles that are used separately in your host and that have different available memory. can go in to see details

[email protected] support-files]# cp my-large.cnf/etc/my.cnfcp:overwrite '/etc/my.cnf '? N

once selected, copy to the/etc/my.cnf file, but you will find that this The file already exists, and you may suspect that we have not installed MySQL and why this file is available. In fact, this file is the system installed Mysql-libs automatically provided configuration files. Please open the/etc/my.cnf file view first, as below will explain the following

[Email protected] support-files]# mkdir/etc/mysql[[email protected] support-files]# cp/usr/local/mysql/ Support-files/my-large.cnf/etc/mysql/my.cnf

If we are covered, some of the configuration information will be different, such as Socket,datadir. So we chose to install to another location. Click to open the new my.cnf, you will find a lot of configuration information will be different from the previous one, so what is mysql to read which configuration information? Here is an introduction

4.7. Modify the path to the MySQL data file (this setting is required)

Add the following to the [Mysqld] section, which means that MySQL data is saved to this path, whether you have modified the path or not, it is best to fill in the path above, and the test will sometimes not generate the corresponding MySQL initial file.

DataDir =/usr/local/mysql/data

4.8. Initialize MySQL

There is a mysql_install_db file under scripts, which is specifically used to initialize MySQL.

You can use the./mysql_install_db–help to view Help information

--datadir=path: Specify the data file storage path

--user=user_name: Which user to use to perform the initialization process, this item cannot be omitted

[Email protected] scripts]#/mysql_install_db--user=mysql–datadir=/usr/local/mysql/data

However, an error will be reported at this time: "FATAL error:could not find/bin/my_print_defaults", because it is necessary to read the file in the bin directory, so the execution must switch to the parent directory to execute the line, the actual following execution

[Email protected] mysql]#/scripts/mysql_install_db--user=mysql

4.9. mysql Service script

Under Support-files, there is a service script called Mysql.server that is ready. As long as the installation directory has not been modified, can be used normally

[email protected] data]# CP. /support-files/mysql.server/etc/rc.d/init.d/mysqld[[email protected] data]# chkconfig mysqld on

4.10. Start Mysqld Service

[[Email protected] data]# service mysqld start

4.11, after the installation of some need to pay attention to the place

In the front we will find that Mysql-libs generated a/etc/my.cnf configuration file, and we created a new/etc/mysql/my.cnf profile ourselves, so we look at the above two configuration files

[Email protected] ~]# vim/etc/my.cnf[mysqld]datadir=/var/lib/mysqlsocket=/var/lib/mysql/mysql.sockuser=mysql[[ Email protected] ~]# Vim/etc/mysql/my.cnf[mysqld]port = 3306socket =/tmp/mysql.sockthread_concurrenc y = 8datadir=/usr/local/mysql/data

We can see that the socket file points to a different file path, so by looking at the file in/tmp it will generate a Mysql.sock file, and/var/lib/mysql does not have this file, which means that the read configuration file/etc/mysql/my.cnf takes effect.

This is a bit of a special MySQL, MySQL read the configuration file it is not read only one, he will go to find a number of places, and then find the last one to find the final use of the configuration, or he found all the, and then the inside of the parameters to merge, And if you have the same parameters in all the configuration files, the last time you find one is the final entry.

4.12, the program files can not find a solution

Because it is not installed with the RPM package, it is possible that the program files cannot be found, then you need to edit the configuration file environment variable path, so that its program in the environment variable path can be found

[Email protected] tmp]# vim/etc/profile.d/mysql.shexport path=/usr/local/mysql/bin: $PATH

Reread configuration Files

[Email protected] tmp]# source/etc/profile.d/mysql.sh

At this point you can execute the MySQL program, or the previous execution of MySQL will prompt the program can not find the error message.

4.13. Lead-in document

If we need him to develop, or rely on other programs to compile, we need to export

[Email protected] tmp]# ln-sv/usr/local/mysql/include//usr/include/mysql '/usr/include/mysql '/usr/local/ mysql/include/'

4.14. Lead-in document

[Email protected] tmp]# Ldconfig-v |  grep mysql/usr/lib64/mysql:libmysqlclient_r.so.16-libmysqlclient_r.so.16.0.0 libmysqlclient.so.16 libmysqlclient.so.16.0.0

However, this library file is provided by the RPM package of mysql-libs.

So do the following:

[Email protected] tmp]# Vim/etc/ld.so.conf.d/mysql.conf/usr/local/mysql/lib

Reload to view

[Email protected] tmp]# Ldconfig-v | grep mysql/usr/local/mysql/lib:libmysqlclient.so.18-libmysqlclient_r.so.18.0.0libmysqld.so.18 libmysqld.so.18/usr/lib64/mysql:libmysqlclient_r.so.16, libmysqlclient_r.so.16.0.0libmysqlclient.so.16, libmysqlclient.so.16.0.0

4.15. Use MySQL to connect to MySQL server

[Email protected] mysql]# Mysqlwelcome to the MariaDB Monitor. Commands End With; or \g.your MariaDB connection ID is 3Server version:5.5.36-mariadb-log MariaDB servercopyright (c) #, Oracle, Mo Nty program Ab and others. Type ' help ', ' or ' \h ' for help. Type ' \c ' to clear the current input statement. MariaDB [(None)]>

The version information for the MySQL server is described here, and the version of MARIADB 5.5.36 is used.



V. Summary

5.1, the extracted files must be placed in the/usr/local directory

5.2. The directory name of the file directory must be MySQL, otherwise it will affect the script execution error in the generic binary package.


This article is from the "Crab Learn Linux" blog, please be sure to keep this source http://windchasereric.blog.51cto.com/5419433/1703025

Universal binary installation MySQL (MariaDB)

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.