Ubuntu下安裝MariaDB

本文的初衷僅供自己做備忘筆記, 內(nèi)容大多從網(wǎng)上搜集和整理, 并非都是自己原創(chuàng).
參考的來源我會(huì)在后面注明, 對(duì)于可能遺漏的來源, 還請(qǐng)相關(guān)原創(chuàng)作者提醒, 非常感謝.

資料參考:
https://www.cnblogs.com/lzwangshubo/p/9977997.html
https://mariadb.com/kb/en/library/mariadb-package-repository-setup-and-usage/

環(huán)境&版本

  • MairaDB 10.1.43
  • Ubuntu 18.04

更新倉庫(非必要)

這一步其實(shí)不是必須的, 而是MariaDB推薦的. Ubuntu的Repository里的穩(wěn)定版可能會(huì)比較老, 不是社區(qū)最新的穩(wěn)定版. 因此MairaDB提供了更新倉庫的腳步.
執(zhí)行

curl -sS https://downloads.mariadb.com/MariaDB/mariadb_repo_setup | sudo bash

這個(gè)腳本會(huì)設(shè)置3個(gè)不同的倉庫到配置文件中, 包括:

  • MariaDB Repository
  • MariaDB MaxScale Repository
  • MariaDB Tools Repository

安裝服務(wù)

sudo apt install mariadb-server

這里我曾經(jīng)使用sudo apt install mariadb-server-10.4進(jìn)行安裝, 然而后續(xù)操作時(shí)出現(xiàn)了問題, 導(dǎo)致卸載重裝了

啟動(dòng)服務(wù)

啟動(dòng)mariadb

sudo systemctl start mariadb

允許mariadb自啟動(dòng)

sudo systemctl enable mariadb

初始化配置

這一步很重要

$ sudo mysql_secure_installation

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we'll need the current
password for the root user. If you've just installed MariaDB, and
haven't set the root password yet, you should just press enter here.

Enter current password for root (enter for none): //因?yàn)橹皼]有設(shè)置密碼,所以直接回車
OK, successfully used password, moving on...

Setting the root password or using the unix_socket ensures that nobody
can log into the MariaDB root user without the proper authorisation.

You already have your root account protected, so you can safely answer 'n'.

Switch to unix_socket authentication [Y/n] n //不使用unix_socket authentication
 ... skipping.

You already have your root account protected, so you can safely answer 'n'.

Change the root password? [Y/n] y //設(shè)置root密碼
New password: 
Re-enter new password: 
Password updated successfully!
Reloading privilege tables..
 ... Success!


By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] y //刪除匿名用戶
 ... Success!

Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] y //禁止遠(yuǎn)程登錄root
 ... Success!

By default, MariaDB comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] y //刪除測(cè)試數(shù)據(jù)庫
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] y //刷新權(quán)限
 ... Success!

Cleaning up...

All done!  If you've completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容