Centos7 x86_64 安装MariaDB

本文介绍如何在CentOS7上安装并配置MariaDB数据库。首先需要移除系统默认的Mysql/MariaDB,然后可以通过yum源或RPM包进行安装。文中详细介绍了两种安装方法的具体步骤,并给出了配置MariaDB的指导。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1. 全部删除系统自带的Mysql/MariaDB

  • MySQL 已经不再包含在 CentOS 7 的源中,而改用了 MariaDB;MySQL 已经不再包含在 CentOS 7 的源中,而改用了 MariaDB;如果存在,使用:

    sudo rpm -e –nodeps mariadb-* //全部删除

    或者:

    sudo yum remove mysql mysql-server mysql-libs compat-mysql51

2.安装 MariaDB

MariaDB有三种安装方式,源码安装、yum安装、rpm离线包安装。
源码安装很麻烦,还会遇到一些错误,不建议新手使用。所以这里给出yum 和rpm 离线包安装两种方式。

yum 安装

  • 添加MariaDB的yum源

sudo vim /etc/yum.repos.d/MariaDB.repo

将下面的内容粘贴进去:

# MariaDB 10.0 CentOS repository list - created 2017-01-04 03:11 UTC
# http://downloads.mariadb.org/mariadb/repositories/
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.0/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1

  • 安装 MariaDB

    sudo yum install MariaDB-server MariaDB-client


如果想安装其他版本的MariaDB 可以参考 MariaDB官网。 yum源安装的好处是简单方便,通过简单的命令行yum 会帮你全部搞定,但是可能对有些网速不好的朋友来说,yum安装速度会慢的让你无法忍受,还会出现用户退出安装。下面就可以通过rpm 离线包安装

使用RPM包离线安装MariaDB 10.1.20

  • 进入MariaDB官网下载MariaDB需要的RPM包

    我是centos7 64 选 10.1.20 —> centos7-amd64—>rpms ,需要下载:
    MariaDB-10.1.20-centos7-x86_64-common.rpm
    MariaDB-10.1.20-centos7-x86_64-compat.rpm
    galera-25.3.19-1.rhel7.el7.centos.x86_64.rpm
    jemalloc-3.6.0-1.el7.x86_64.rpm
    jemalloc-devel-3.6.0-1.el7.x86_64.rpm
    MariaDB-10.1.20-centos7-x86_64-client.rpm
    MariaDB-10.1.20-centos7-x86_64-server.rpm
    接下来:

    sudo rpm -ivh XXX.rpm

如果还需要其他依赖,请自行搜索安装^_^

3. 配置MariaDB

After the installation completes, start MariaDB with:

sudo systemctl start mariadb

sudo systemctl start mysql.service
sudo systemctl stop mysql.service

//好使

service mysql start

设置root密码

mysqladmin -u root password ‘root’

登录数据库

mysql -u root -p

如果从其它机器登录:

mysql -h ip地址 -u root -p

PLEASE REMEMBER TO SET A PASSWORD FOR THE MariaDB root USER !
To do so, start the server, then issue the following commands:

‘/usr/bin/mysqladmin’ -u root password ‘new-password’
‘/usr/bin/mysqladmin’ -u root -h localhost.localdomain password ‘new-password’

Alternatively you can run:
‘/usr/bin/mysql_secure_installation’

which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers.

See the MariaDB Knowledgebase at http://mariadb.com/kb or the
MySQL manual for more instructions.

Please report any problems at http://mariadb.org/jira

The latest information about MariaDB is available at http://mariadb.org/.
You can find additional information about the MySQL part at:
http://dev.mysql.com
Consider joining MariaDB’s strong and vibrant community:
https://mariadb.org/get-involved/

从您的描述来看,您遇到了与 MariaDB 相关的包依赖冲突问题。以下是详细的解释: ### 解释: 1. **MariaDB-common** 是一个包含公共组件的基础软件包,通常用于支持其他更高版本的 MariaDB 组件。 2. 您提到的 `MariaDB-compat-10.2.14-1.el7.centos.x86_64` 包需要的是较旧版本的 `mariadb-libs`(即 `< 1:10.1.0`),这意味着它期望安装的库版本低于指定范围。 3. 然而,在系统环境中可能存在更新版的 `mariadb-libs`,这导致了兼容性冲突。例如,当前正在尝试安装或替换的 `MariaDB-compat-10.2.14-1.el7.centos x86_64` 已经取代了原本的 `g mariadb-libs`。 这种情况通常是由于不同版本间的依赖链断裂引起的,常见于跨主版本升级或者同时存在多个存储库的情况下。 --- ### 解决方案建议: #### 方法一:清理并重新同步 yum 缓存 运行以下命令清除缓存,并强制刷新 YUM 存储库数据: ```bash yum clean all yum makecache ``` 然后再次尝试安装所需的 MariaDB 软件包组合。 #### 方法二:手动排除特定版本 如果您确定不再使用某些较高版本的库文件,则可以显式地禁止其加载。例如通过编辑 `/etc/yum.conf` 文件添加一行规则来阻止目标 RPM 的引入: ``` exclude=mariadb-libs >= 1:10.1.0 ``` 接着再试一次正常流程操作即可解决部分简单场景下的类似错误提示信息。 #### 方法三:选择适配的具体分支构建号 考虑到官方维护团队针对每个发行平台提供专门定制化的解决方案;如果上述步骤未能成功解决问题的话,那么最好下载适合 CentOS 7 平台对应的完整离线安装介质集合进行覆盖处理。(访问 https://downloads.mariadb.org 下载最新稳定版本) ---
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值