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

相關文章
相關標籤/搜索