本文介绍在CentOS Linux 7.7系统上安装和配置MariaDB数据库的过程,包括防火墙设置、SELinux状态确认、通过YUM安装MariaDB,以及服务启动和安全初始化步骤。
//系统
# less /etc/redhat-release
CentOS Linux release 7.7.1908 (AltArch)# uname -r
4.19.84-v7l.1.el7
//firewall设置
# firewall-cmd --zone=public --permanent --add-service=mysql# firewall-cmd --reload# firewall-cmd --list-service //可以看到MySQL已经打开
//SELinux设置
# getsebool
getsebool: SELinux is disabled
//mariadb版本
# mysql -V
mysql Ver 15.1 Distrib 5.5.64-MariaDB, for Linux (armv7l) using readline 5.1
//yum安装
# yum -y install mariadb mariadb-devel mariadb-server
//mariadb提供了一些my.cnf示例,在 /usr/share/mysql 路径中,可以阅读参考README.mysql-cnf
//后附一个自己用的示例
# systemctl start mariadb.service //启动服务# systemctl enable mariadb.service //设置开机自启
//检查进程、端口
# lsof -i:3306# ps aux|grep mysql# /usr/bin/mysql_secure_installation //进行安全设置(初始化)===================分割线===================
Enter current password for root (enter for none): #没密码直接回车
Set root password? [Y/n]: Y # 设置密码
New password: your-MariaDB-root-password
Re-enter new password: your-MariaDB-root-password
Remove anonymous users? [Y/n]: Y # 删除匿名账户
Disallow root login remotely? [Y/n]: n # 是否禁止管理员从远程登录
Remove test database and access to it? [Y/n]: Y # 删除test数据库并取消访问
Reload privilege tables now? [Y/n]: Y # 刷新授权表,让初始化后生效===================分割线===================