1 配置yum源
1.1 查找mariadb软件包地址
打开http://mirrors.aliyun.com/,查找mariadb,然后拼装地址http://mirrors.aliyun.com/mariadb/yum打开,点开想要的版本,选择对应的操作系统点进去,复制地址,我这里是http://mirrors.aliyun.com/mariadb/yum/10.6.16/centos7-amd64/
1.2 新建一个源
cat > /etc/yum.repos.d/MariaDB.repo <<'EOF'
[mariadb]
name = MariaDB
baseurl = http://mirrors.aliyun.com/mariadb/yum/10.6.16/centos7-amd64/
gpgkey = http://mirrors.aliyun.com/mariadb/yum/RPM-GPG-KEY-MariaDB
gpgcheck = 1
EOF
清除缓存
yum clean all
2 安装并启动MariaDB
2.1 安装
yum install -y MariaDB-server MariaDB-client
2.2 启动
安装完成MariaDB,启动MariaDB并设置开机启动
systemctl enable --now mariadb # 等同执行一下两条命令
# 启动MariaDB
systemctl start mariadb
# 设置开机启动
systemctl enable mariadb
3 配置
# 修改root密码,默认是空
mysqladmin -u root password "Root123456!2"
# 配置允许远程访问
mysql<<'EOF'
grant all privileges on *.* to 'root'@'%' identified by "Root123456!2";
flush privileges;
EOF
4 测试远程连接mariadb数据库
mysql -h 192.168.2.14 -P3306 -uroot -p'Root123456!2'