測試環境
- CentOS 7
- MariaDB 10.3
執行原因
在 MairiaDB 安裝完成時會出現提示訊息如下:

執行 mysql_secure_installation (安全設定) 會設定以下功能
- root 帳號設定密碼
- 刪除匿名帳號
- 取消root帳號遠端登入
- 刪除test資料庫及Test 資料庫訪問權
- 載入設定資料庫內容,使修改生效
執行步驟
執行此設定可以提高mysql資料庫安全性,建議正式環境安裝完成後一定要執行一次”mysql_secure_installation”。
輸入下面指令後按列步驟執行
/usr/bin/mysql_secure_installation
1.設定 root 密碼
預設root密碼為空白,請按Enter

Set root password? “Y”
設定 root 密碼 “Y”

輸入兩次密碼

2.移除 anonymous 使用者
Remove anonymous users? “Y”
移除 anonymous 使用者? “Y”

3.關閉root 帳號遠端登入
Disallow root login remotely?”Y”
禁止 root 遠端登入”Y”

4.移除測試資料庫及權限
Remove test database and access to it? “Y”
移除測試資料庫跟訪問權? “Y”

5.重新載入資料庫權限設定
Reload privilege tables now? “Y”
現在重新載入權限表? “Y”

6.完成設定
完成後如下圖
