Explain how to install MariaDB 10.2.4 in centos7


The server / client installation package for MySQL is provided in CentOS 6 and earlier versions, but CentOS 7 has replaced the default MySQL with MariaDB. MariaDB database management system is a branch of MySQL, which is mainly maintained by the open source community. The purpose of using GPL to license MariaDB is fully compatible with MySQL, including API and command line, so that it can easily become a substitute for MySQL.

1. Delete MySQL / MariaDB

1.1 search for existing packages of MariaDB

Use RPM – QA | grep MariaDB to search for existing packages in MariaDB. If it exists, use RPM – E — nodeps MariaDB – * to delete all:

[[email protected] ~]# rpm -qa | grep mariadb
[[email protected] ~]# rpm -e mysql-*

Error: package MySQL is not installed-*

1.2. Remove the existing package of MariaDB

If it exists, useyum remove mysql mysql-server mysql-libs compat-mysql51 Delete all:

[[email protected] ~]# yum remove mysql mysql-server mysql-libs compat-mysql51
Loaded plug-ins: fastmirror, langpacks
Parameter MySQL does not match
The parameter MySQL server does not match
The parameter compat-mysql51 does not match
Resolving dependencies
-->Checking transactions
--->Software package mariadb-libs.x86_ will be deleted
-->Processing dependencies libmysqlclient.so . 18 () (64bit), which is supported by perl-dbd-mysql-4.023-5.el7.x86_ 64 need
-->Processing dependencies libmysqlclient.so . 18 () (64bit), which is included in package 2: postfix-2.10.1-6.el7.x86_ 64 need
-->Processing dependencies libmysqlclient.so . 18 () (64bit), which is included in the package 1: qt-mysql-4.8.5-13.el7.x86_ 64 need to
 mariadb-libs.x86_64 1:5.5.52-1.el7                      
 akonadi-mysql.x86_64 0:1.9.2-4.el7   mariadb-server.x86_64 1:5.5.52-1.el7  
 perl-DBD-MySQL.x86_64 0:4.023-5.el7  postfix.x86_64 2:2.10.1-6.el7     
 qt-mysql.x86_64 1:4.8.5-13.el7    
[[email protected] ~]# rpm -qa|grep mariadb
[[email protected] ~]#

2. MariaDB installation

2. Server and client installation

[[email protected] ~]# yum -y install MariaDB-server MariaDB-client
Loaded plugins: fastestmirror, langpacks
(1/7): epel/7/x86_64/updateinfo
(7/7): pgdg95/7/x86_64/primary_db
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
--> Finished Dependency Resolution
Dependencies Resolved
 Package               Arch        Version
 MariaDB-client           x86_64       10.2.4-1.el7.centos
 MariaDB-server           x86_64       10.2.4-1.el7.centos
Installing for dependencies:
 MariaDB-common           x86_64       10.2.4-1.el7.centos
 MariaDB-compat           x86_64       
Transaction Summary
Install 2 Packages (+12 Dependent packages)
Total size: 173 M
Total download size: 113 M
Installed size: 731 M




[[email protected] ~]# systemctl start mariadb
[[email protected] ~]# systemctl enable mariadb
[[email protected] ~]# systemctl restart mariadb
[[email protected] ~]# systemctl stop mariadb.service


[[email protected] ~]# mysql -uroot -p123456


[[email protected] etc]# cat /etc/my.cnf

If / etc/ my.cnf None in. D directory server.cnf File, then directly in / etc/ my.cnf Add the above content under the [mysqld] tag of the file


init_connect='SET collation_connection = utf8_unicode_ci' 
init_connect='SET NAMES utf8' 

  [[email protected] my.cnf.d]# mysql -uroot -p123456
  MariaDB [(none)]> show variables like "%character%";show variables like "%collation%";


MariaDB [(none)]> create user [email protected] identified by '123456';
MariaDB [(none)]> grant all on *.* to [email protected] identified by '123456';
MariaDB [(none)]> grant all privileges on *.* to [email protected]'%' identified by '123456';
MariaDB [(none)]> grant all privileges on *.* to [email protected]'master' identified by '123456' with grant option;
MariaDB [(none)]> use mysql;

MariaDB [mysql]> select host,user,password from user;


Forget the root user name and password

First usekillall -TERM mysqld Send the kill command to mysqld server to shut down mysqld server (not kill – 9). You must be a UNIX root user or an equivalent user on the server you are running to perform this operation

then/usr/bin/mysqld_safe --skip-grant-tables --skip-networking &

Login: MySQL – P or use Mysql to login without password

use mysql
update user set password=password(“new_pass”) where user=“root”;
flush privileges;

After the modification, restart the database and log in with the modified root password


The above is the method of centos7 installing MariaDB 10.2.4. I hope it will be helpful to you. If you have any questions, please leave me a message, and the editor will reply to you in time. Thank you very much for your support to the developeppaer website!
If you think this article is helpful to you, welcome to reprint, please indicate the source, thank you!