linux系統在線安裝、配置MariaDB(MariaDB 10.5為例)


一、安裝MariaDB

1.訪問網址

  https://downloads.mariadb.org/mariadb/repositories/#distro=CentOS&distro_release=centos8-amd64--centos8&mirror=tuna&version=10.5

2.  ①選擇服務器系統

     ②選擇服務器系統版本

     ③選擇將要安裝的MariaDB版本(如圖)

 

 

 

 3.   在服務器運行

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

  把以下代碼復制進該文件並保存。

  這是CentOS的自定義存儲庫條目。將其復制並粘貼到/etc/yum.repos.d/下的文件中(建議將文件命名為MariaDB.repo或類似的名稱)

 

# MariaDB 10.5 CentOS repository list - created 2021-07-06 07:11 UTC
# http://downloads.mariadb.org/mariadb/repositories/
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.5/centos8-amd64
module_hotfixes=1      #是解決被告知的dnf錯誤的方法
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1

如圖:

4.安裝並啟動MariaDB

sudo dnf install MariaDB-server
sudo systemctl start mariadb

二、配置MariaDB

1. 啟動MariaDB服務

service mysql start

2.配置MariaDB

mysql_secure_installation

  2.1  Enter current password for root (enter for none):    //輸入當前密碼,初次安裝沒有密碼,直接回車

  2.2  Switch to unix_socket authentication [Y/n] n     //詢問是否使用'unix_socket'進行身份驗證:n

  2.3  Change the root password? [Y/n] y         //為root設置密碼:y

    New password:                   //輸入密碼

    Re-enter new password:               //再次輸入密碼

  2.4  Remove anonymous users? [Y/n] y        //是否移除匿名用戶,這個隨意,建議刪除:y

  2.5  Disallow root login remotely? [Y/n] n        //拒絕用戶遠程登錄,這個建議開啟:n

  2.6  Remove test database and access to it? [Y/n] n     //刪除test庫,可以保留:n

  2.7 Reload privilege tables now? [Y/n] y        //重新加載權限表:y

3.進入MariaDB控制台

mysql -u root -p

4.賦予root用戶遠程連接權限

grant all privileges on *.* to 'root'@'%' identified by 'root密碼';

5.刷新權限

flush privileges;

6.測試遠程連接


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM