In CentOS 7, MariaDB source code package is compiled and installed, and centosmariadb

Source: Internet
Author: User

In CentOS 7, MariaDB source code package is compiled and installed, and centosmariadb

Download the installation package

Download the MariaDB 10.2 stable version source code package from the official website.

Select source code package

After you click the link, the page will jump to the download page. You can enter an Information table on the page. Here we will skip it. Click No thanks, just take me to the download, and save the source package.

Save the source code package:

/usr/local/src/

 

Decompress:

tar zxvf mariadb-10.2.13.tar.gz

 

 

Preparations before Compilation

Install the dependency package required by Mariadb:

yum -y install readline-devel zlib-devel openssl-devel libaio-devel

Create the database installation directory and data directory:

mkdir /usr/local/mysql/
mkdir /data/

Add mysql users and user groups:

groupadd -r mysqluseradd -g mysql -s /sbin/nologin -M mysql

Grant directory permissions:

chown mysql:mysql /data/

 

Start compilation and Installation

Go to the decompressed installation directory:

cd mariadb-10.2.13/

Compilation settings:

cmake . \-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \-DMYSQL_DATADIR=/data \-DSYSCONFDIR=/etc \-DWITHOUT_TOKUDB=1 \-DMYSQL_UNIX_ADDR=/tmp/mysql.sock \-DDEFAULT_CHARSET=utf8 \-DDEFAULT_COLLATION=utf8_general_ci

Parameter description:

-DCMAKE_INSTALL_PREFIX # specify the installation path
-DMYSQL_DATADIR # specify the data directory
-DSYSCONFDIR # specifies the directory where the database configuration file is located, which is generally stored in the/etc directory.
-DWITHOUT_TOKUDB # This parameter must be set. If it is set to 1, the tokudb engine is not installed.
-DDEFAULT_CHARSET # Set the default Character Set
-DDEFAULT_COLLATION # Set the default encoding

Note: if an error occurs during compilation, you can delete cmakecache.txt. Otherwise, an error is returned even if the correct command is used:
rm -rf CMakeCache.txt

Compile and install:

make && make install

 

Follow-up after installation

Go to the mysql installation directory and run the following commands:

cd /usr/local/mysql
chown -R mysql:mysql ../scripts/mysql_install_db --datadir=/data --user=mysqlchown -R root:root .cp support-files/mysql.server /etc/init.d/mysqld
chown -R mysql:mysql .

Add mysqld to System Service:

Chkconfig -- add mysqld # add to System Service chkconfig mysqld on # Set startup

Create a log file:

mkdir /var/log/mariadb

Create a sock soft link:

ln -s /var/lib/mysql/mysql.sock /tmp/mysql.sock

Running Service:

support-files/mysql.server start

Log on to mysql. The default user password is root:

./bin/mysql -u 'root' -p

Login successful:

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.