Centos7.5_1804 yum安装Mariadb详细图文步骤

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)

当你尝试卸载 MariaDB 并遇到警告信息“/etc/my.cnf 已另存为 /etc/my.cnf.rpmsave”,这通常意味着 RPM 包管理工具检测到当前配置文件 `/etc/my.cnf` 存在自定义修改,并为了避免丢失用户的个性化设置而将其备份。 ### 解释: 1. **原因**:RPM 系统发现现有的配置文件与原始安装包提供的默认版本不同。为了保护用户所做的更改,在卸载过程中会将原文件保存为 `.rpmsave` 文件,即原来的 `/etc/my.cnf` 被移动到了 `/etc/my.cnf.rpmsave`。 2. **影响**:这个操作本身不会对系统造成损害,只是提醒你注意配置文件的变化。如果你不需要保留旧的配置文件,则可以安全地忽略该消息;如果希望恢复之前的数据库服务状态并继续使用相同的配置项,则需要手动复制相关内容至新的环境中(如果有新安装其他 MySQL/MariaDB 版本的话)。 3. **处理建议**: - 如果不再需要此配置文件,可以直接删除 `/etc/my.cnf.rpmsave` 或者留作参考; - 若要保留原有配置并在未来重新安装时应用它们,请妥善保管好这份 rpmsave 文件,并在适当时候迁移回正式的位置 (`/etc/my.cnf`) 或整合进新版软件对应的配置路径下。 4. **进一步清理步骤**:确保彻底清除所有相关的残留数据和服务记录,如日志、库文件等。对于 Linux 发行版而言,可以通过命令行检查是否有剩余的 mariadb 相关包未完全移除: ```bash sudo yum autoremove mariadb* # 对于基于 RedHat 的发行版如 CentOS/RHEL sudo apt-get purge mariadb-* # 针对 Debian 和 Ubuntu 类系统 ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值