Centos7 a fresh install the latest stable version of MariaDB 10.3 Series

Adding MariaDB 10.3 yum domestic sources, the new file as follows:

nano /etc/yum.repos.d/Mariadb.repo

 Add the following:

[mariadb]
name = MariaDB
baseurl = https://mirrors.ustc.edu.cn/mariadb/yum/10.3/centos7-amd64
gpgkey=https://mirrors.ustc.edu.cn/mariadb/yum/RPM-GPG-KEY-MariaDB
gpgcheck=1

 

Clear yum source cache data

yum clean all

Generating new source data cache yum

yum makecache all

Installation mariadb10.3

yum install MariaDB-server MariaDB-client -y

Start and add the boot from Kai:

systemctl start mariadb.service
systemctl enable mariadb.service

mariadb initialization, I see another article Blog: https://blog.csdn.net/evkj2013/article/details/82859780

After completing the above configuration, the database file is saved in the default location, how to customize it? The following changes to save the database file location.

Change the default database to store directory data to / data / mysql_data / mysql

First, determine the MariaDB database to run correctly.

service mysql status

After determining the normal database

systemctl stop mariadb

To change the build directory data store, such as: I have a separate sub-district / data storage MariaDB data

mkdir /data/mysql_data 
chown -R mysql:mysql /data/mysql_data

Copy the default folders to store data / data / mysql_data

cp -a /var/lib/mysql    /data/mysql_data

Modify /etc/my.cnf.d/server.cnf

nano /etc/my.cnf.d/server.cnf

Add the following in [mysqld] tab

#--------------------------add by root-----------------------------
# add for moving data to /data/mysql_data
#
datadir=/data/mysql_data/mysql
socket=/var/lib/mysql/mysql.sock
#default-character-set=utf8
character_set_server=utf8
slow_query_log=on
slow_query_log_file=/data/mysql_data/slow_query_log.log
long_query_time=2
#--------------------------end-------------------------------------

Configuring MariaDB slow queries

touch /data/mysql_data/slow_query_log.log
chown mysql:mysql /data/mysql_data/slow_query_log.log

Start the database, it's done

systemctl start mariadb

Restart command is as follows:

systemctl restart mariadb

In this resolved:

1, my.cnf configuration file exists, but does not modify the my.cnf, but /etc/my.cnf.d/server.cnf;

2, no change mysql.sock path configuration;

3, no content of /etc/init.d/mysql;

4, no content of mysql_safe;

5, an increase of slow queries configuration database.

Reference connection: https://www.cnblogs.com/ld1977/p/7264485.html

eVK
Published 34 original articles · won praise 19 · Views 750,000 +

Guess you like

Origin blog.csdn.net/yongzhen150/article/details/84799048