Detailed explanation of how to install MariaDB 10.2.4 on CentOS7

Detailed explanation of how to install MariaDB 10.2.4 on CentOS7

CentOS 6 and earlier versions provide MySQL server/client installation packages, but CentOS 7 has used MariaDB to replace the default MySQL. MariaDB database management system is a branch of MySQL, mainly maintained by the open source community. It uses the GPL license. The purpose of MariaDB is to be fully compatible with MySQL, including API and command line, so that it can easily become a substitute for MySQL.

1. Delete the built-in MySQL/MariaDB

1.1. Search for existing MariaDB packages

Use rpm -qa | grep mariadb to search for the existing MariaDB package. If they exist, use rpm -e --nodeps mariadb-* to remove them all:

[root@master ~]# rpm -qa | grep mariadb
mariadb-server-5.5.52-1.el7.x86_64
mariadb-libs-5.5.52-1.el7.x86_64
[root@localhost ~]# rpm -e mysql-*

Error: Package mysql-* not installed

1.2. Remove existing MariaDB packages

If it exists, use yum remove mysql mysql-server mysql-libs compat-mysql51 to delete all:

[root@master ~]# yum remove mysql mysql-server mysql-libs compat-mysql51
Loaded plugins: fastestmirror, langpacks
Parameter mysql not matched Parameter mysql-server not matched Parameter compat-mysql51 not matched Resolving dependencies--> Checking transactions---> Package mariadb-libs.x86_64.1.5.5.52-1.el7 will be removed--> Processing dependency libmysqlclient.so.18()(64bit), which is needed by package perl-DBD-MySQL-4.023-5.el7.x86_64--> Processing dependency libmysqlclient.so.18()(64bit), which is needed by package 2:postfix-2.10.1-6.el7.x86_64--> Processing dependency libmysqlclient.so.18()(64bit), which is needed by package 1:qt-mysql-4.8.5-13.el7.x86_64..........
delete:
 mariadb-libs.x86_64 1:5.5.52-1.el7                      
Removed as a dependency:
 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    
complete!
[root@master ~]# rpm -qa|grep mariadb
[root@master ~]#

2. MariaDB installation

2. Server and Client Installation

[root@master ~]# 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
==============================================================================
Installing:
 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
  ...

Complete!

insert image description here
insert image description here

insert image description here

[root@master ~]# systemctl start mariadb
[root@master ~]# systemctl enable mariadb
[root@master ~]# systemctl restart mariadb
[root@master ~]# systemctl stop mariadb.service 

insert image description here

[root@master ~]# mysql -uroot -p123456 

insert image description here

[root@master etc]# cat /etc/my.cnf

If there is no server.cnf file in the /etc/my.cnf.d directory, add the following content directly under the [mysqld] tag in the /etc/my.cnf file:

insert image description here

init_connect = 'SET collation_connection = utf8_unicode_ci' 
init_connect='SET NAMES utf8' 
character-set-server=utf8 
collation-server=utf8_unicode_ci 
skip-character-set-client-handshake

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

insert image description here


MariaDB [(none)]> create user mariadb@localhost identified by '123456';
MariaDB [(none)]> grant all on *.* to mariadb@localhost identified by '123456';
MariaDB [(none)]> grant all privileges on *.* to mariadb@'%' identified by '123456';
MariaDB [(none)]> grant all privileges on *.* to mariadb@'master' identified by '123456' with grant option;
MariaDB [(none)]> use mysql;
MariaDB [mysql]> select host,user,password from user; 

insert image description here
insert image description here

Forgot root username and password

First, use killall -TERM mysqld to send a kill command to the mysqld server to shut down the mysqld server (not kill -9). You must be the root user of UNIX 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 log in without password

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

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

Summarize

The above is the method of installing MariaDB 10.2.4 on CentOS7 introduced by the editor. I hope it will be helpful to everyone. If you have any questions, please leave me a message and the editor will reply to you in time. I would also like to thank everyone for their support of the 123WORDPRESS.COM website!
If you find this article helpful, please feel free to reprint it and please indicate the source. Thank you!

You may also be interested in:
  • How to install MySQL and MariaDB in Docker
  • Docker implements MariaDB sub-library and sub-table and read-write separation functions
  • How to run mariadb program in docker
  • How to create a MariaDB image in Docker
  • Pycharm remotely connects to the mariadb database in the vagrant virtual machine
  • Detailed discussion of the differences and performance comparison between MySQL and MariaDB
  • MariaDB under Linux starts with the root user (recommended)
  • MySQL/MariaDB Root Password Reset Tutorial
  • A brief discussion on the difference between MySQL and MariaDB (performance comparison between mariadb and mysql)
  • Analysis of the configuration process of installing mariadb based on docker

<<:  jQuery achieves seamless scrolling of tables

>>:  MySQL DML statement summary

Recommend

Example of how to quickly delete a 2T table in mysql in Innodb

Preface This article mainly introduces the releva...

Summary of using MySQL online DDL gh-ost

background: As a DBA, most of the DDL changes of ...

Summary of some efficient magic operators in JS

JavaScript now releases a new version every year,...

A simple way to build a Docker environment

First, let’s understand what Docker is? Docker is...

Vue realizes the function of book shopping cart

This article example shares the specific code of ...

In-depth analysis of HTML semantics and its related front-end frameworks

About semantics Semantics is the study of the rel...

JavaScript to implement drop-down list selection box

This article example shares the specific code of ...

Detailed explanation of the function and usage of DOCTYPE declaration

1. Browser rendering mode and doctype Some web pa...

Solve the problem of not finding NULL from set operation to mysql not like

An interesting discovery: There is a table with a...

Vue3+TypeScript implements a complete example of a recursive menu component

Table of contents Preface need accomplish First R...

How to manually upgrade the kernel in deepin linux

deepin and Ubuntu are both distributions based on...

MySQL parameter related concepts and query change methods

Preface: In some previous articles, we often see ...

Jenkins Docker static agent node build process

A static node is fixed on a machine and is starte...