Ubuntu安装Mariadb

2020-10-14  本文已影响0人  鹊南飞_

1. 官方地址

https://downloads.mariadb.org/mariadb/repositories

2. 打开后根据自己的版本选择

3. 选择后会出现对应的命令

我的选择是操作系统Ubuntu 20.04Mariadb版本10.5,清华大学源

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. 安装成功后可以查看数据库版本

mysql --version

5. 进行简单的配置

mysql_secure_installation
root@VM-0-8-ubuntu:/home/ubuntu# mysql_secure_installation
#输入root(mysql)的密码。默认没有,直接回车
Enter current password for root (enter for none): 
#是否切换到unix套接字身份验证[Y/n]
Switch to unix_socket authentication [Y/n] n
#是否设置root密码
Change the root password? [Y/n] y
# 输入两次密码
New password:
Re-enter new password:
#是否删除匿名用户?(就是空用户),建议删除
Remove anonymous users? [Y/n] y
#是否不允许远程root登录
Disallow root login remotely? [Y/n] n
#是否删除test数据库
Remove test database and access to it? [Y/n] y
#是否加载权限使之生效
Reload privilege tables now? [Y/n] y

6. 配置远程访问权限

cd /etc/mysql
grep -rn "skip-networking" ./

# 发现以下文件,为下一步做准备
# ./mariadb.conf.d/50-server.cnf:28:# Instead of skip-networking the default is now to listen only on
vim mariadb.conf.d/50-server.cnf
mysql
use mysql;
select host from user where user='root';

+-----------+
| Host      |
+-----------+
| localhost |
+-----------+
1 row in set (0.001 sec)
# 密码自行修改,我这里设置为@admin123
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '@admin123' WITH GRANT OPTION;
flush privileges;
select host from user where user='root';
+-----------+
| Host      |
+-----------+
| %         |
| localhost |
+-----------+
2 rows in set (0.001 sec)

  1. 连接测试


    连接测试
上一篇下一篇

猜你喜欢

热点阅读