前言

MariaDB 数据库管理系统是 MySQL 的一个分支,主要由开源社区在维护,采用 GPL 授权许可。

安装 MariaDB 5.5

通过yum安装MariaDB 5.5

1
yum install mariadb mariadb-server mariadb-devel mariadb-libs –y

配置MariaDB 5.5

1
2
3
4
5
6
7
8
9
10
11
12
systemctl start mariadb  # 开启服务
systemctl enable mariadb # 开机自启动
mysql_secure_installation # 数据库的配置

Enter current password for root (enter for none): # 第一次进入还没有设置密码则直接回车跳过
Set root password? [Y/n] # # 设置密码,y确认
New password: # 输入新密码
Re-enter new password: # 再次输入
Remove anonymous users? [Y/n] # 是否移除匿名用户
Disallow root login remotely? [Y/n] # 是否拒绝root远程登录
Remove test database and access to it? [Y/n] # 是否删除test数据库
Reload privilege tables now? [Y/n] # 重新加载权限表

测试连接MariaDB 5.5

1
2
3
4
5
mysql -u root -p
Enter password: # 输入刚才设置的密码
Welcome to the MariaDB monitor....
.....
MariaDB [(none)]> #显示此行证明MariaDB成功安装并正常运行

安装MariaDB 10.9

配置repo源

1
2
3
4
5
6
7
8
9
cd /etc/yum.repos.d/
vim MariaDB.repo

[mariadb]
name = MariaDB
baseurl = https://mirrors.aliyun.com/mariadb/yum/10.9/centos7-amd64/
module_hotfixes = 1
gpgkey = https://mirrors.aliyun.com/mariadb/yum/RPM-GPG-KEY-MariaDB
gpgcheck = 1

通过yum安装MariaDB 10.9

1
2
yum install -y mariadb-server mariadb-client
rpm -ivh http://www.ivarch.com/programs/rpms/pv-1.6.20-1.x86_64.rpm # 如果出现缺失pv软件包

配置MariaDB 10.9

1
2
3
4
5
6
7
8
9
10
11
12
systemctl start mariadb
systemctl enable mariadb
mariadb-secure-installation

Enter current password for root (enter for none): # 第一次进入还没有设置密码则直接回车跳过
Set root password? [Y/n] # # 设置密码,y确认
New password: # 输入新密码
Re-enter new password: # 再次输入
Remove anonymous users? [Y/n] # 是否移除匿名用户
Disallow root login remotely? [Y/n] # 是否拒绝root远程登录
Remove test database and access to it? [Y/n] # 是否删除test数据库
Reload privilege tables now? [Y/n] # 重新加载权限表

测试连接MariaDB 10.9

1
2
3
4
5
mysql -u root -p
Enter password: # 输入刚才设置的密码
Welcome to the MariaDB monitor....
.....
MariaDB [(none)]> #显示此行证明MariaDB成功安装并正常运行