1. 删除旧版本的mariadb
[root@localhost home]#
[root@localhost home]# rpm -qa | grep mariadb
mariadb-libs-5.5.68-1.el7.x86_64
[root@localhost home]# yum remove mariadb-libs-5.5.68-1.el7.x86_64
已加载插件:fastestmirror
正在解决依赖关系
--> 正在检查事务
---> 软件包 mariadb-libs.x86_64.1.5.5.68-1.el7 将被 删除
--> 正在处理依赖关系 libmysqlclient.so.18()(64bit),它被软件包 2:postfix-2.10.1-9.el7.x86_64 需要
--> 正在处理依赖关系 libmysqlclient.so.18(libmysqlclient_18)(64bit),它被软件包 2:postfix-2.10.1-9.el7.x86_64 需要
--> 正在检查事务
---> 软件包 postfix.x86_64.2.2.10.1-9.el7 将被 删除
--> 解决依赖关系完成
依赖关系解决
==============================================================
Package 架构 版本 源 大小
==============================================================
正在删除:
mariadb-libs x86_64 1:5.5.68-1.el7 @base 4.4 M
为依赖而移除:
postfix x86_64 2:2.10.1-9.el7 @base 12 M
事务概要
==============================================================
移除 1 软件包 (+1 依赖软件包)
安装大小:17 M
是否继续?[y/N]:y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
正在删除 : 2:postfix-2.10.1-9.el7.x86_64 1/2
正在删除 : 1:mariadb-libs-5.5.68-1.el7.x86_64 2/2
验证中 : 1:mariadb-libs-5.5.68-1.el7.x86_64 1/2
验证中 : 2:postfix-2.10.1-9.el7.x86_64 2/2
删除:
mariadb-libs.x86_64 1:5.5.68-1.el7
作为依赖被删除:
postfix.x86_64 2:2.10.1-9.el7
完毕!
[root@localhost home]#
2. 安装 mariadb 服务
# yum install -y mariadb-server
3. 安装 mariadb 命令行客户端
# yum install -y mariadb
4. 安装 mariadb C library
# yum install -y mariadb-libs
5. 安装 mariadb 开发包
# yum install -y mariadb-devel
6. 修改配置
1.更改 /etc/my.cnf.d/client.cnf 文件
# vi /etc/my.cnf.d/client.cnf
[client]
default-character-set = utf8
[client-mariadb]
2.更改 /etc/my.cnf.d/mysql-clients.cnf 文件,
[mysql]的 下加一行添加 default-character-set=utf8
# vi /etc/my.cnf.d/mysql-clients.cnf
#
# These groups are read by MariaDB command-line tools
# Use it for options that affect only one utility
#
[mysql]
default-character-set = utf8
[mysql_upgrade]
[mysqladmin]
[mysqlbinlog]
[mysqlcheck]
[mysqldump]
[mysqlimport]
[mysqlshow]
[mysqlslap]
3.更改 /etc/my.cnf.d/server.cnf 配置
[mysqld] 下方添加
collation-server = utf8_general_ci
init-connect='SET NAMES utf8'
character-set-server = utf8
sql-mode = TRADITIONAL
最终内容
#
# These groups are read by MariaDB server.
# Use it for options that only the server (but not clients) should see
#
# See the examples of server my.cnf files in /usr/share/mysql/
#
# this is read by the standalone daemon and embedded servers
[server]
# this is only for the mysqld standalone daemon
[mysqld]
collation-server = utf8_general_ci
init-connect = 'SET NAMES utf8'
character-set-server = utf8
sql-mode = TRADITIONAL
# this is only for embedded server
[embedded]
# This group is only read by MariaDB-5.5 servers.
# If you use the same .cnf file for MariaDB of different versions,
# use this group for options that older servers don't understand
[mysqld-5.5]
# These two groups are only read by MariaDB servers, not by MySQL.
# If you use the same .cnf file for MySQL and MariaDB,
# you can put MariaDB-only options here
[mariadb]
[mariadb-5.5]
7. 启动数据库
启动服务
# systemctl start mariadb
设置服务开启自启动
# systemctl enable mariadb
查看服务状态
# systemctl status mariadb
可能的输出为,注意到 Active 状态为 active (running)