CentOS yum 安装、卸载MariaDB数据库

1、安装Mariadb

[root@localhost~]# yum -y install mariadb-server

2、启动服务并设置开机启动

[root@localhost~]# systemctl start mariadb
[root@localhost~]# systemctl enable mariadb

3、配置MariaDB

[root@localhost~]# mysql_secure_installation

#输入当前root密码
Entercurrent password for root (enter for none):

#设置root密码?
Changethe root password?[Y/n]

#删除匿名用户?
Removeanonymous users?[Y/n]

#禁止root用户远程登录?
Disallowroot login remotely?[Y/n]

#删除test数据库?
Removetest database and access to it? [Y/n]

#重新加载权限表?
Reloadprivilege tables now? [Y/n]

4、配置MariaDB字符编码(以utf8mb4为例)

[root@localhost~]# vi /etc/my.cnf

#在[mysqld]标签下添加
character-set-server=utf8mb4  
[root@localhost~]# vi /etc/my.cnf.d/client.cnf

#在[client]标签下添加
default-character-set=utf8mb4

5、重启启动MariaDB服务

[root@localhost~]# systemctl restart mariadb 

6、查看MariaDB字符编码

MariaDB[(none)]show variables like ‘%character%’;  

7、卸载MariaDB数据库

[root@localhost~]# rpm -aq|grep mariadb  
mariadb-libs-5.5.50-1.e17_2.x86_64  
mariadb-5.5.50-1.e17_2.x86_64  
mariadb-server-5.5.50-1.e17_2.x86_64  
[root@localhost~]# yum -y remove mariadb*

推荐阅读更多精彩内容