CentOS7中安装MariaDB

什么是mariaDB?

  • 在线安装(慢的要命)
  • RPM离线安装(CentOS7.X)

在线安装

  1. 打开官方网站 mariadb.org/
    图1
  2. 点击Download,跳转到下一页面
    图2
  3. 继续点击Download,进到下页
    图3
  4. 点击红框中的[连接] (https://downloads.mariadb.org/mariadb/repositories/#mirror=23Media),进到一下页面
    图4
  5. 根据本身的服务器的类型/版原本选择要安装的数据库版本.
    按照上述步骤能够在线安装。

离线安装

  1. 点击图4中的baseurl
    图5
  2. 点击rpms, 能够看到一堆rpm包,不要着急,继续看下一步
    图6
  3. 打开MariaDB org --> Learn --> [MariaDB Knowledge Base] --> MariaDB Server -->

Getting, Installing, and Upgrading MariaDB --> MariaDB Binary Packages --> Installing MariaDB RPM Files --> MariaDB Installation (Version 10.1.21) via RPMs on CentOS 7java

最终的url点击以后,就能够看到以下图所示界面:
图7
原本彻底能够提供最终的一个url,提供一步一步点击的按钮链接,是为了方便你们来学习路线思路,而不能只拿结果。
node

  1. 还记得咱们以前第二步看到的一堆rpm包吗? 下载第三步方框中的package,固然,这个文档的版本稍有点落后,可是咱们只须要搜索前缀名称就好了,好比搜索client:
    图8
    咱们下载最新版本就能够了。
    接下来进入正式步骤了哦~:
    在图7中有Step by step installation:

Step by step installation:mysql

- 1) First install all of the dependencies needed. Its easy to do this via YUM packages: yum install rsync nmap lsof perl-DBI ncspring

- 2) rpm -ivh jemalloc-3.6.0-1.el7.x86_64.rpmsql

- 3) rpm -ivh jemalloc-devel-3.6.0-1.el7.x86_64.rpm数据库

- 4) rpm -ivh MariaDB-10.1.21-centos7-x8664-common.rpm MariaDB-10.1.21-centos7-x8664-compat.rpm MariaDB-10.1.21-centos7-x8664-client.rpm galera-25.3.19-1.rhel7.el7.centos.x8664.rpm MariaDB-10.1.21-centos7-x86_64-server.rpmsegmentfault

按照步骤咱们开始:
centos

  1. 安装依赖信息,命令行执行:
[root@iZ2ze7s2v0b78922wia32rZ software]#  yum install rsync nmap lsof perl-DBI nc复制代码

  1. 安装咱们以前下载的版本jemalloc-3.6.0-1.el7.x86_64.rpm
[root@iZ2ze7s2v0b78922wia32rZ mariadb]# rpm -ivh jemalloc-3.6.0-1.el7.x86_64.rpm 复制代码

  1. 安装jemalloc-devel-3.6.0-1.el7.x86_64.rpm
[root@iZ2ze7s2v0b78922wia32rZ mariadb]# rpm -ivh jemalloc-devel-3.6.0-1.el7.x86_64.rpm复制代码

  1. 安装剩余的mariadb相关的包,必定要注意顺序.common > compat > client > galera > server
[root@iZ2ze7s2v0b78922wia32rZ mariadb]# rpm -ivh MariaDB-common-10.4.8-1.el7.centos.x86_64.rpm MariaDB-compat-10.4.8-1.el7.centos.x86_64.rpm MariaDB-client-10.4.8-1.el7.centos.x86_64.rpm galera-4-26.4.3-1.rhel7.el7.centos.x86_64.rpm MariaDB-server-10.4.8-1.el7.centos.x86_64.rpm 
   warning: MariaDB-common-10.4.8-1.el7.centos.x86_64.rpm: Header V4 DSA/SHA1 Signature, key ID 1bb943db: NOKEY
   error: Failed dependencies:
           mariadb-libs < 1:10.1.0 conflicts with MariaDB-compat-10.4.8-1.el7.centos.x86_64
           mariadb-libs is obsoleted by MariaDB-compat-10.4.8-1.el7.centos.x86_64
           libaio.so.1()(64bit) is needed by MariaDB-client-10.4.8-1.el7.centos.x86_64
           libaio.so.1(LIBAIO_0.1)(64bit) is needed by MariaDB-client-10.4.8-1.el7.centos.x86_64
           libaio.so.1(LIBAIO_0.4)(64bit) is needed by MariaDB-client-10.4.8-1.el7.centos.x86_64
           libboost_program_options.so.1.53.0()(64bit) is needed by galera-4-26.4.3-1.rhel7.el7.centos.x86_64
           libaio.so.1()(64bit) is needed by MariaDB-server-10.4.8-1.el7.centos.x86_64
           libaio.so.1(LIBAIO_0.1)(64bit) is needed by MariaDB-server-10.4.8-1.el7.centos.x86_64
           libaio.so.1(LIBAIO_0.4)(64bit) is needed by MariaDB-server-10.4.8-1.el7.centos.x86_64复制代码

执行以后发现报错,仍是在图7显示页面,咱们能够看见Step by step installation: 段落结束以后有这么一句: Here is the error message for dependencies:安全

`服务器

rpm -ivh MariaDB-10.1.21-centos7-x86_64-common.rpm

warning: MariaDB-10.1.21-centos7-x86_64-common.rpm: Header V4 DSA/SHA1 Signature, key ID 1bb943db: NOKEY

error: Failed dependencies:

mariadb-libs < 1:10.1.21-1.el7.centos conflicts with MariaDB-common-10.1.21-1.el7.centos.x86_64

`

是否是和咱们的错误很类似?按照官方提供的solution就能够解决了。

后续还有几个错误,一样按照官方给出的解决方案处理,一步一步就搞定了,以下:

[root@iZ2ze7s2v0b78922wia32rZ mariadb]# rpm -qa | grep mariadb-libs
   mariadb-libs-5.5.60-1.el7_5.x86_64
   [root@iZ2ze7s2v0b78922wia32rZ mariadb]# rpm -ev --nodeps mariadb-libs-5.5.60-1.el7_5.x86_64
   Preparing packages...
   mariadb-libs-1:5.5.60-1.el7_5.x86_64
   [root@iZ2ze7s2v0b78922wia32rZ mariadb]# rpm -qa | grep mariadb-libs                        
   [root@iZ2ze7s2v0b78922wia32rZ mariadb]# yum install boost-devel.x86_64
   Loaded plugins: fastestmirror
   Loading mirror speeds from cached hostfile
   Resolving Dependencies
   --> Running transaction check
   ...
   Is this ok [y/d/N]: y
   ...
   
   Complete!
   [root@iZ2ze7s2v0b78922wia32rZ mariadb]# rpm --import http://yum.mariadb.org/RPM-GPG-KEY-MariaDB复制代码

而后从新回到安装的第四步:

[root@iZ2ze7s2v0b78922wia32rZ mariadb]# rpm -ivh MariaDB-common-10.4.8-1.el7.centos.x86_64.rpm MariaDB-compat-10.4.8-1.el7.centos.x86_64.rpm MariaDB-client-10.4.8-1.el7.centos.x86_64.rpm galera-4-26.4.3-1.rhel7.el7.centos.x86_64.rpm MariaDB-server-10.4.8-1.el7.centos.x86_64.rpm 
   error: Failed dependencies:
           libaio.so.1()(64bit) is needed by MariaDB-client-10.4.8-1.el7.centos.x86_64
           libaio.so.1(LIBAIO_0.1)(64bit) is needed by MariaDB-client-10.4.8-1.el7.centos.x86_64
           libaio.so.1(LIBAIO_0.4)(64bit) is needed by MariaDB-client-10.4.8-1.el7.centos.x86_64
           libaio.so.1()(64bit) is needed by MariaDB-server-10.4.8-1.el7.centos.x86_64
           libaio.so.1(LIBAIO_0.1)(64bit) is needed by MariaDB-server-10.4.8-1.el7.centos.x86_64
           libaio.so.1(LIBAIO_0.4)(64bit) is needed by MariaDB-server-10.4.8-1.el7.centos.x86_64复制代码

发现仍是报错???

joke1

这个是官方在10.4.8中新引入的一个问题,须要下载一个依赖包libaio:

[root@iZ2ze7s2v0b78922wia32rZ mariadb]# wget http://mirror.centos.org/centos/6/os/x86_64/Packages/libaio-0.3.107-10.el6.x86_64.rpm
   --2019-11-28 10:52:26--  http://mirror.centos.org/centos/6/os/x86_64/Packages/libaio-0.3.107-10.el6.x86_64.rpm复制代码

下载成功以后,安装一下当前下载的依赖包:

[root@iZ2ze7s2v0b78922wia32rZ mariadb]# rpm -ivh libaio-0.3.107-10.el6.x86_64.rpm复制代码


而后再一次重复Step 4:

[root@iZ2ze7s2v0b78922wia32rZ mariadb]# rpm -ivh MariaDB-common-10.4.8-1.el7.centos.x86_64.rpm MariaDB-compat-10.4.8-1.el7.centos.x86_64.rpm MariaDB-client-10.4.8-1.el7.centos.x86_64.rpm galera-4-26.4.3-1.rhel7.el7.centos.x86_64.rpm MariaDB-server-10.4.8-1.el7.centos.x86_64.rpm 
   Preparing...                          ################################# [100%]
   Updating / installing...
      1:MariaDB-compat-10.4.8-1.el7.cento################################# [ 20%]
      2:MariaDB-common-10.4.8-1.el7.cento################################# [ 40%]
      3:MariaDB-client-10.4.8-1.el7.cento################################# [ 60%]
      4:galera-4-26.4.3-1.rhel7.el7.cento################################# [ 80%]
      5:MariaDB-server-10.4.8-1.el7.cento################################# [100%]
   
   
   Two all-privilege accounts were created.
   One is root@localhost, it has no password, but you need to
   be system 'root' user to connect. Use, for example, sudo mysql
   The second is mysql@localhost, it has no password either, but
   you need to be the system 'mysql' user to connect.
   After connecting you can set the password, if you would need to be
   able to connect as any of these users with a password and without sudo
   
   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/复制代码

终于安装成功了。。。
joke2

接下来,最后一步配置数据库:

# 启动mariaDB,(由于mariaDB是mysql做者写的新的数据库,其实服务和mysql是同样的,因此启动使用的是下面)
[root@iZ2ze7s2v0b78922wia32rZ ~]# service mysql start
# 安全配置
[root@iZ2ze7s2v0b78922wia32rZ ~]# mysql_secure_installation
# 输入root密码,安装后第一次启动为空,直接回车
Enter current password for root (enter for none): 
# step 1: 是否切换到unix_socket安全认证,否
Switch to unix_socket authentication [Y/n] n
# step 2: 更改密码,选择修改
Change the root password? [Y/n] y
# step 3: 移除匿名用户,选择是
Remove anonymous users? [Y/n] y
# step 4: 是否容许root远程登陆,根据我的需求,由于我是测试服务器选择容许
Disallow root login remotely? [Y/n] y
# step 5: 移除test数据库
Remove test database and access to it? [Y/n] y
# step 6: 从新加载权限表
Reload privilege tables now? [Y/n] y
# 看到下面,说明成功啦!!!
All done!  If you've completed all of the above steps, your MariaDB
installation should now be secure.
Thanks for using MariaDB!复制代码

测试

登陆数据库:

[root@iZ2ze7s2v0b78922wia32rZ ~]# mysql -u root -p复制代码

修改root远程链接权限

MariaDB [(none)]> grant all privileges on *.* to 'root'@'%' identified by 'your password';
Query OK, 0 rows affected (0.001 sec)

MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.000 sec)复制代码

客户端远程链接

远程链接成功示意图

奔跑的人生 | 博客园 | segmentfault | spring4all | csdn | 掘金 | OSChina | 简书 | 头条 | 知乎 | 51CTO

相关文章
相关标签/搜索