1. 官方地址
https://downloads.mariadb.org/mariadb/repositories
2. 打開后根據(jù)自己的版本選擇
- 選擇操作系統(tǒng)版本
- 選擇
Mariadb
版本 - 選擇鏡像源
3. 選擇后會出現(xiàn)對應(yīng)的命令
我的選擇是操作系統(tǒng)Ubuntu 20.04
,Mariadb
版本10.5
,清華大學(xué)源
sudo apt-get install software-properties-common
sudo apt-key adv --fetch-keys 'https://mariadb.org/mariadb_release_signing_key.asc'
sudo add-apt-repository 'deb [arch=amd64,arm64,ppc64el] [https://mirrors.tuna.tsinghua.edu.cn/mariadb/repo/10.5/ubuntu](https://mirrors.tuna.tsinghua.edu.cn/mariadb/repo/10.5/ubuntu) focal main'
sudo apt update
sudo apt install mariadb-server
4. 安裝成功后可以查看數(shù)據(jù)庫版本
mysql --version
5. 進(jìn)行簡單的配置
mysql_secure_installation
root@VM-0-8-ubuntu:/home/ubuntu# mysql_secure_installation
#輸入root(mysql)的密碼。默認(rèn)沒有,直接回車
Enter current password for root (enter for none):
#是否切換到unix套接字身份驗證[Y/n]
Switch to unix_socket authentication [Y/n] n
#是否設(shè)置root密碼
Change the root password? [Y/n] y
# 輸入兩次密碼
New password:
Re-enter new password:
#是否刪除匿名用戶?(就是空用戶),建議刪除
Remove anonymous users? [Y/n] y
#是否不允許遠(yuǎn)程root登錄
Disallow root login remotely? [Y/n] n
#是否刪除test數(shù)據(jù)庫
Remove test database and access to it? [Y/n] y
#是否加載權(quán)限使之生效
Reload privilege tables now? [Y/n] y
6. 配置遠(yuǎn)程訪問權(quán)限
- 切換目錄
cd /etc/mysql
- 查找文件
grep -rn "skip-networking" ./
# 發(fā)現(xiàn)以下文件,為下一步做準(zhǔn)備
# ./mariadb.conf.d/50-server.cnf:28:# Instead of skip-networking the default is now to listen only on
- 編輯文件,注釋掉
bind-address
項
vim mariadb.conf.d/50-server.cnf
- 進(jìn)入
mysql
mysql
- 切換數(shù)據(jù)庫
use mysql;
- 查看用戶信息
select host from user where user='root';
+-----------+
| Host |
+-----------+
| localhost |
+-----------+
1 row in set (0.001 sec)
- 設(shè)置遠(yuǎn)程連接的密碼
# 密碼自行修改,我這里設(shè)置為@admin123
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '@admin123' WITH GRANT OPTION;
- 刷新權(quán)限
flush privileges;
- 重新查看用戶信息
select host from user where user='root';
+-----------+
| Host |
+-----------+
| % |
| localhost |
+-----------+
2 rows in set (0.001 sec)
-
連接測試
連接測試