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

Vue implements tree table

This article example shares the specific code of ...

Use of MySQL triggers

Triggers can cause other SQL code to run before o...

Use Rem layout to achieve adaptive

I have written an article about mobile adaptation...

JavaScript Basics Operators

Table of contents 1. Operators Summarize 1. Opera...

Detailed explanation of the difference between chown and chmod commands in Linux

In Linux system, both chmod and chown commands ca...

Detailed tutorial on running selenium+chromedriver on the server

1. Introduction I want to use selenium to scrape ...

MySQL character set garbled characters and solutions

Preface A character set is a set of symbols and e...

Better looking CSS custom styles (title h1 h2 h3)

Rendering Commonly used styles in Blog Garden /*T...

How to use MySQL group by and order by together

Suppose there is a table: reward (reward table), ...

Example analysis of mysql variable usage [system variables, user variables]

This article uses examples to illustrate the usag...

A brief discussion on the font settings in web pages

Setting the font for the entire site has always b...

How to modify the mysql table partitioning program

How to modify the mysql table partitioning progra...

javascript countdown prompt box

This article example shares the specific code of ...

Vue custom component implements two-way binding

Scenario: The interaction methods between parent ...