CentOS7升级MariaDB 10.2版本详细步骤

  • Post author:
  • Post category:其他


#查看mariadb运行状态: systemctl status mariadb 
#启动mariadb: systemctl start mariadb
#停止mariadb :systemctl stop mariadb 
#重新启动 :systemctl restart mariadb 
#开机启动: systemctl enable mariadb 


1、查看sql版本:# mysql --version
mysql  Ver 15.1 Distrib 5.5.64-MariaDB, for Linux (x86_64) using readline 5.1

2、查看使用状态:# systemctl status mariadb

3、查看自带安装信息:# rpm -qa | grep -i mariadb
mariadb-5.5.64-1.el7.x86_64
mariadb-server-5.5.64-1.el7.x86_64
mariadb-libs-5.5.64-1.el7.x86_64
4、查看自带安装信息:# yum list|grep mariadb
mariadb.x86_64                            1:5.5.64-1.el7               @os
mariadb-libs.x86_64                       1:5.5.64-1.el7               @os
mariadb-server.x86_64                     1:5.5.64-1.el7               @os
mariadb-bench.x86_64                      1:5.5.64-1.el7               os
mariadb-devel.i686                        1:5.5.64-1.el7               os
mariadb-devel.x86_64                      1:5.5.64-1.el7               os
mariadb-embedded.i686                     1:5.5.64-1.el7               os
mariadb-embedded.x86_64                   1:5.5.64-1.el7               os
mariadb-embedded-devel.i686               1:5.5.64-1.el7               os
mariadb-embedded-devel.x86_64             1:5.5.64-1.el7               os
mariadb-libs.i686                         1:5.5.64-1.el7               os
mariadb-test.x86_64                       1:5.5.64-1.el7               os

5、停止服务运行并查看:# systemctl stop mariadb && systemctl status mariadb
6、开始卸载# yum remove -y mariadb && yum remove -y mariadb-*
7、#已搜不到安装信息
# yum list installed |grep mariadb
# rpm -qa|grep mariadb
# find / -name mysql
/var/lib/mysql
/usr/lib64/mysql
# rm -rf /var/lib/mysql/
# rm -rf /var/lib64/mysql/
# find / -name mariadb
/var/log/mariadb
# rm -rf /var/log/mariadb
8、配置yum源为国内地址:# vim /etc/yum.repos.d/Mariadb.repo
录入以下内容
[mariadb]
name = MariaDB
baseurl = https://mirrors.ustc.edu.cn/mariadb/yum/10.2/centos7-amd64
gpgkey=https://mirrors.ustc.edu.cn/mariadb/yum/RPM-GPG-KEY-MariaDB
gpgcheck=1
9、清除yum源缓存数据,并生成新的yum源数据缓存
# yum clean all && yum makecache all
10、查看下载缓存信息
# ll /var/cache/yum/x86_64/7/mariadb
12、开始安装
# yum install MariaDB-server MariaDB-client -y
....
已安装:
  MariaDB-client.x86_64 0:10.2.31-1.el7.centos                                   MariaDB-server.x86_64 0:10.2.31-1.el7.centos

作为依赖被安装:
  MariaDB-common.x86_64 0:10.2.31-1.el7.centos         MariaDB-compat.x86_64 0:10.2.31-1.el7.centos         boost-program-options.x86_64 0:1.53.0-27.el7
  galera.x86_64 0:25.3.28-1.rhel7.el7.centos

完毕!
13、启动mariadb
# systemctl start mariadb.service
14、初始化配置信息(设置root密码)
# /usr/bin/mysql_secure_installation

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we'll need the current
password for the root user.  If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none):
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.

Set root password? [Y/n] y
New password:你的密码
Re-enter new password:你的密码
Password updated successfully!
Reloading privilege tables..
 ... Success!


By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] y
 ... Success!

Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] n
 ... skipping.

By default, MariaDB comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] y
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] y
 ... Success!

Cleaning up...

All done!  If you've completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!
安装完成
15、创建初始化数据库(创建数据库如下图)
# mysql -uroot -p
Enter password:
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 20
Server version: 10.2.31-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> 
mysql> use mysql;
mysql> CREATE USER 'glpi'@'%' IDENTIFIED BY 'glpi';   #用户名 密码
mysql> GRANT USAGE ON *.* TO 'glpi'@'%' IDENTIFIED BY 'glpi';
mysql> create database glpi;
mysql>grant select,insert,update,delete,create,drop on glpi.* to 'glpi'@'%';
mysql> quit

16、#重新启动 :systemctl restart mariadb

17、#开机启动: systemctl enable mariadb




版权声明:本文为m0_54501831原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。