MariaDB Introduction
The MariaDB database management system is a branch of MySQL. It is mainly maintained by the open-source community and licensed by GPL. One of the reasons for developing this branch is that after Oracle acquired MySQL, there is a potential risk of closing the source of MySQL. Therefore, the community uses the branch method to avoid this risk. MariaDB is designed to be fully compatible with MySQL, including APIs and command lines, so that it can easily become a substitute for MySQL. In terms of storage engine, XtraDB is used to replace InnoDB of MySQL.
Next, let's compile and install and use a MariaDB
Compile and install MariaDB
Note: MariaDB is compiled and installed in the same way as MySQL.
1. Prepare the data directory (logical volume) in the production environment)
# Fdisk/dev/sda create a logical partition/dev/sda6
Create logical volume # pvcreate/dev/sda6 # vgcreate myvg/dev/sda6 # lvcreate-L 10G-n mydata/dev/myvg format logical volume # mke2fs-t ext4/dev/ myvg/mydata
Create a data DIRECTORY # mkdir-pv/mydata/data mount the logical volume to the data directory and add it to automatic mounting upon startup
2. Create a mysql user mysql group (Considering Application Security)
# Groupadd-r mysql CREATE mysql group # useradd-g mysql-r-d/mydata/data create mysql user # chown mysql; mysql/mydata/data Change the owner Group of the data Directory
3. Install the compiler cmake
# Yum-y install cmake
Install a specific development kit (to prevent compilation errors) # yum-y install readline-devel zlib-devel openssl-devel
Cmake specifies the compilation option in a different way than make, and its implementation method is compared as follows :. /configure cmake .. /configure -- help cmake. -LH or specifies the option that is often used when the installation path of the Installation File is:-DCMAKE_INSTALL_PREFIX =/usr/local/mysql-DMYSQL_DATADIR =/data/mysql-DSYSCONFDIR =/etc default compiled storage engines include: csv, myisam, myisammrg, and heap. To install other storage engines, you can use the following compilation options:-DWITH_INNOBASE_STORAGE_ENGINE = engines = 1-DWITH_BLACKHOLE_STORAGE_ENGINE = 1-DWITH_FEDERATED_STORAGE_ENGINE = 1. To explicitly specify not to compile a storage engine, you can use the following options:-DWITHOUT _ <ENGINE> _ STORAGE_ENGINE = 1 For example:-DWITHOUT_EXAMPLE_STORAGE_ENGINE = 1-DWITHOUT_FEDERATED_STORAGE_ENGINE = 1 If You Want To compile other functions, such as SSL, you can use the following options to implement a library at compile time or do not use a library:-DWITH_READLINE = 1-DWITH_SSL = system-DWITH_ZLIB = 0 other commonly used options: -DMYSQL_TCP_PORT = 3306-DMYSQL_UNIX_ADDR =/tmp/mysql. sock-DENABLED_LOCAL_INFILE = 1-DEXTRA_CHARSETS = all-DDEFAULT_CHARSET = utf8-DDEFAULT_COLLATION = utf8_general_ci-DWITH_DEBUG = 0-DENABLE_PROFILING = 1 if you want to clear the files generated by the previous compilation, use the following command: make cleanrm CMakeCache.txt
4. Download The MariaDB source code package 5.5.36.
# Https://downloads.mariadb.org/interstitial/mariadb-5.5.36/kvm-tarbake-jaunty-x86/mariadb-5.5.36.tar.gz/from/http://mirrors.tuna.tsinghua.edu.cn/mariadb
5. Compile and install
# Tar xf mariadb-5.5.36.tar.gz # cd mariadb-5.5.36 # cmake. -DCMAKE_INSTALL_PREFIX =/usr/local/mysql-DMYSQL_DATADIR =/mydata/data/-DSYSCONFDIR =/etc-keys = 1-keys = 1-keys = 1-DWIYH_READLINE = 1-DWIYH_SSL = system-DVITH_ZLIB = system-DWITH_LOBWRAP = 0-DMYSQL_UNIX_ADDR =/tmp/mysql. sock-DDEFAULT_CHARSET = utf8-DDEFAULT_COLLATION = utf8_general_ci # make & make install
6. Prepare the MariaDB script and configuration file.
Initialize database # cd/usr/local/mysql # chown-R mysql: mysql * change owner group # scripts/mysql_install_db -- datadir =/mydata/data -- user = mysql initialization library file # chown-R root * change owner to root
Provide the script # cd/usr/local/mysql # cp support-files/mysql. server/etc/rc. d/init. d/mysqld provides the script # chmod + x/etc/rc. d/init. d/mysqld grant execution permission # chkconfig -- add mysqld as system service # chkconfig mysqld on add as startup
Provide the configuration file # cd/usr/local/mysql # cp support-files/my-large.cnf/etc/my. cnf # vim/etc/my. cnf edit configuration file [mysqld] section fill in the following content [mysqld] datadir =/mydata/data DIRECTORY thread_concurrency = 4 set the number of threads = number of cores x2
7. Provide binary files, library files, header files, man Manual
Provide the binary file # echo 'export PATH =/usr/local/mysql/bin: $ path'>/etc/profile. d/mysql. sh provides the library file # echo '/usr/local/mysql/lib'>/etc/ld. so. conf. d/mysql. conf provides the header file # ln-sv/usr/local/include/usr/include/mysql provides the man manual # echo 'manpath/usr/local/mysql'>/etc/man. config # man-M/usr/local/mysql/man mysqld make the man manual take effect immediately
8. Start the service and connect to the MariaDB Server
Start service # service mysqld start # ss-ntl | grep: 3306
Initialize MariaDB
1. initialize the first operation.
Configuration file my. cnf centralized Configuration: the configuration file [mysqld] [mysqld_safe] [client] shared by multiple applications is used to view all configuration information of the mysql server # cd/usr/local/mysql/bin #. /mysqld -- help -- verbose | head-20 Default options are read from the following filesinthe given order:/etc/mysql/my. conf/etc/my. cnf ~ /. My. conf uses the configuration file method 1. it searches for each file to be searched, and the result is the union of all files 2. If a parameter appears multiple times in multiple files, then the read results will take effect #/user/local/mysql/bin/mysqld -- help -- verbose1. display the available options when the mysqld program starts, usually it is long option 2. display the available service VARIABLES in the mysqld configuration file mysql> show glogal VARIABLESmysql> SHOW SESSION VARIABLES
2. initialize the second operation.
1. Delete all anonymous users mysql> drop user ''@ 'localhost'; mysql> drop user'' @ '127. 0.0.1 '; 2. Set a password for all root users: mysql> setpasswordforusrName @ hostName = password ('your _ passswd '); method 2: mysql> update usersetpassword = password ('your _ passwd') where user = 'root' mysql> flush privileges; Method 3 (shell command) # mysqladmin-uUserName-hHost password 'new _ passwd'-pHost is the IP address of the remote mysql Server # msyqladmin-uUserName-hHost-p flush-privileges;
Ps: The level is limited. If any error occurs, please point it out.
Let's take a look at the power of MariaDB and make it open-source.
This article from the "Wind thin pig" blog, please be sure to keep this source http://jungege.blog.51cto.com/4102814/1394924