资讯专栏INFORMATION COLUMN

CentOS yum安装MariaDB最新版

Tecode / 2354人阅读

摘要:安装最新版本教程主要讲述全新安装或升级数据库操作基本方法。添加如下内容注意可根据如下地址查看最新版本如安装目前最新版,那么只需要将上边的源改一下即可。

CentOS yum 安装 MariaDB 最新版

本教程主要讲述全新安装 MariaDB 或升级 MariaDB 数据库操作基本方法。

一、删除已安的其他版本的 MariaDB
1、直接命令

rpm -qa | grep mariadb

2、用 yum 删除所列出的所有旧版本
比如:

yum remove mariadb-server-5.5.60-1.el7_5.x86_64

yum remove mariadb-5.5.60-1.el7_5.x86_64

yum remove mariadb-libs-5.5.60-1.el7_5.x86_64

二、创建 MariaDB.repo 源
1、创建 MariaDB 源文件
在目录下 /etc/yum.repos.d/ 创建源文件文件: MariaDB.repo

这里使用 阿里云 源,添加如下内容到 MariaDB.repo 中。

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

添加如下内容

[mariadb]

name = MariaDB

baseurl = http://mirrors.aliyun.com/mariadb/yum/10.4/centos7-amd64/

gpgkey =  http://mirrors.aliyun.com/mariadb/yum/RPM-GPG-KEY-MariaDB

gpgcheck = 1

注意:可根据如下地址查看最新 MariaDB 版本
如CentOS8 安装目前最新版 10.5 ,那么只需要将 上边的 源改一下即可。

[mariadb]

name = MariaDB

baseurl = http://mirrors.aliyun.com/mariadb/yum/10.5/centos8-amd64/

gpgkey =  http://mirrors.aliyun.com/mariadb/yum/RPM-GPG-KEY-MariaDB

gpgcheck = 1

2、清除缓存

yum clean all

yum makecache

3、列出MariaDB 源中的软件包

yum list --disablerepo=* --enablerepo=mariadb
[root@dwtowen /opt/seafile]# yum list --disablerepo=* --enablerepo=mariadb

……

Available Packages
MariaDB-backup.x86_64|| 10.4.8-1.el7.centos|   mariadb
MariaDB-backup-debuginfo.x86_64|        10.4.8-1.el7.centos|   mariadb
MariaDB-cassandra-engine.x86_64|        10.4.8-1.el7.centos|   mariadb
MariaDB-cassandra-engine-debuginfo.x86_64               10.4.8-1.el7.centos|   mariadb
MariaDB-client-debuginfo.x86_64|        10.4.8-1.el7.centos|   mariadb
MariaDB-common-debuginfo.x86_64|        10.4.8-1.el7.centos|   mariadb
MariaDB-connect-engine.x86_64|          10.4.8-1.el7.centos|   mariadb
MariaDB-connect-engine-debuginfo.x86_64|10.4.8-1.el7.centos|   mariadb
MariaDB-cracklib-password-check.x86_64| 10.4.8-1.el7.centos|   mariadb
MariaDB-cracklib-password-check-debuginfo.x86_64        10.4.8-1.el7.centos|   mariadb
MariaDB-devel-debuginfo.x86_64|         10.4.8-1.el7.centos|   mariadb
MariaDB-gssapi-server.x86_64|           10.4.8-1.el7.centos|   mariadb
MariaDB-gssapi-server-debuginfo.x86_64| 10.4.8-1.el7.centos|   mariadb
MariaDB-oqgraph-engine.x86_64|          10.4.8-1.el7.centos|   mariadb
MariaDB-oqgraph-engine-debuginfo.x86_64|10.4.8-1.el7.centos|   mariadb
MariaDB-rocksdb-engine.x86_64|          10.4.8-1.el7.centos|   mariadb
MariaDB-rocksdb-engine-debuginfo.x86_64|10.4.8-1.el7.centos|   mariadb
MariaDB-server-debuginfo.x86_64|        10.4.8-1.el7.centos|   mariadb
MariaDB-shared.x86_64|| 10.4.8-1.el7.centos|   mariadb
MariaDB-shared-debuginfo.x86_64|        10.4.8-1.el7.centos|   mariadb
MariaDB-test.x86_64||   10.4.8-1.el7.centos|   mariadb
MariaDB-test-debuginfo.x86_64|          10.4.8-1.el7.centos|   mariadb
MariaDB-tokudb-engine.x86_64|           10.4.8-1.el7.centos|   mariadb
MariaDB-tokudb-engine-debuginfo.x86_64| 10.4.8-1.el7.centos|   mariadb
jemalloc.x86_64||       3.6.0-1.el7|           mariadb
jemalloc-devel.x86_64|| 3.6.0-1.el7|           mariadb
libzstd.x86_64||        1.3.4-1.el7|           mariadb

三、安装 MariaDB
1、安装 install MariaDB

yum install MariaDB-client MariaDB-server MariaDB-devel -y

CentOS8 下如果报错如下

Last metadata expiration check: 0:13:40 ago on Sun 26 Apr 2020 11:20:57 AM CST.

No match for argument: mysql-community-server

Error: Unable to find a match: mysql-community-server

解决办法:

yum module disable mysql -y
yum module disable mariadb -y
yum install MariaDB-client MariaDB-server MariaDB-devel -y

这样,就可以正常安装了。

2、启动 MariaDB
安装完成后启动 MariaDB

systemctl start mariadb

3、设置 MariaDB 开机自启

systemctl enable mariadb

补充:

MariaDB 常用命令
systemctl 常用命令:

systemctl start mariadb #启动服务


systemctl enable mariadb #设置开机启动


systemctl restart mariadb #重新启动


systemctl stop mariadb.service #停止MariaDB

四、MariaDB 初始化配置
直接命令:

sudo mysql_secure_installation
#先是设置密码,会提示先输入密码


Enter current password for root (enter for none): #<–初次运行直接回车


#设置密码


Set root password? [Y/n] # <– 是否设置root用户密码,输入y并回车或直接回车


New password: # <– 设置root用户的密码


Re-enter new password: # <– 再输入一次你设置的密码


#其他配置


Remove anonymous users? [Y/n] #<– 是否删除匿名用户,Y,回车


Disallow root login remotely? [Y/n] #<–是否禁止root远程登录N,回车


Remove test database and access to it? [Y/n] #<– 是否删除test数据库,n回车


Reload privilege tables now? [Y/n] #<– 是否重新加载权限表,回车

一般情况,到这一步就能正常登陆数据库了

查看数据库版本

mariadb -v
[root@dwtowen /opt/seafile]# mariadb -v

Welcome to the MariaDB monitor.  Commands end with ; or g.

Your MariaDB connection id is 56

Server version: 10.4.8-MariaDB MariaDB Server


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

五、登陆 MariaDB

mysql -u root -p
[root@dwtowen /opt/seafile]# mysql

Welcome to the MariaDB monitor.  Commands end with ; or g.

Your MariaDB connection id is 39

Server version: 10.4.8-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)]>

文章版权归作者所有,未经允许请勿转载,若此文章存在违规行为,您可以联系管理员删除。

转载请注明本文地址:https://www.ucloud.cn/yun/126131.html

相关文章

  • centos7下利用yum搭建LAMP环境

    摘要:方法一安装数据库的相关命令是启动停止重启设置开机启动所以先启动数据库方法二官网下载安装安装成功后重启服务。 由于在阿里云上重置了系统,所以得重新搭建环境,搭建过程中遇到不少坑,在网上搜索之后才得以解决,在这里做个记录,方便日后直接看自己博文。 一:安装Apache 1、安装Apache yum -y install httpd 2、Apache配置httpd.conf 通过命令 fi...

    smartlion 评论0 收藏0
  • centos7下利用yum搭建LAMP环境

    摘要:方法一安装数据库的相关命令是启动停止重启设置开机启动所以先启动数据库方法二官网下载安装安装成功后重启服务。 由于在阿里云上重置了系统,所以得重新搭建环境,搭建过程中遇到不少坑,在网上搜索之后才得以解决,在这里做个记录,方便日后直接看自己博文。 一:安装Apache 1、安装Apache yum -y install httpd 2、Apache配置httpd.conf 通过命令 fi...

    CastlePeaK 评论0 收藏0

发表评论

0条评论

最新活动
阅读需要支付1元查看
<