安装很简单 直接执行命令就行了

yum -y install mariadb-server mariadb
  • 1.

但是之前已经在这里安装了mariadb 这个数据库了,现在一直无法启动,那么又重新安装

发现还是无法启动,那肯定是因为没有卸载干净,现在我们就来说说如何将原来的mariadb卸载干净然后再重新安装

第一步:移除相关的安装包,先执行 yum remove mariadb

[root@openstack2 my.cnf.d]# yum remove mariadb
Loaded plugins: fastestmirror
Resolving Dependencies
--> Running transaction check
---> Package mariadb.x86_64 3:10.1.20-2.el7 will be erased
--> Processing Dependency: mysql(x86-64) for package: 3:mariadb-server-10.1.20-2.el7.x86_64
--> Processing Dependency: mysql-compat-client(x86-64) for package: 3:mariadb-server-10.1.20-2.el7.x86_64
--> Running transaction check
---> Package mariadb-server.x86_64 3:10.1.20-2.el7 will be erased
--> Finished Dependency Resolution
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.

 第二步:查询mariadb 相关的数据包,然后删除 rpm -qa | grep 'mariadb'

[root@openstack2 my.cnf.d]# rpm -qa | grep 'mariadb'
mariadb-config-10.1.20-2.el7.x86_64
mariadb-libs-10.1.20-2.el7.x86_64
mariadb-common-10.1.20-2.el7.x86_64
mariadb-errmsg-10.1.20-2.el7.x86_64
[root@openstack2 my.cnf.d]# rm -f mariadb-config-10.1.20-2.el7.x86_64
[root@openstack2 my.cnf.d]# rm -f mariadb-libs-10.1.20-2.el7.x86_64
[root@openstack2 my.cnf.d]# rm -f mariadb-common-10.1.20-2.el7.x86_64
[root@openstack2 my.cnf.d]# rm -f mariadb-errmsg-10.1.20-2.el7.x86_64
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.

 第三步:删除相关的 /etc/my.cnf 文件 和 /etc/my.cnf.d 文件夹

[root@openstack2 my.cnf.d]# rm -f /etc/my.cnf
[root@openstack2 my.cnf.d]# rm -rf /etc/my.cnf.d/
  • 1.
  • 2.

第四步:安装数据库 yum -y install mariadb-server  mariadb

[root@openstack2 etc]# yum -y install mariadb-server mariadb
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
base                                                                                                                                   | 3.6 kB  00:00:00     
epel                                                                                                                                   | 4.7 kB  00:00:00     
extras                                                                                                                                 | 2.9 kB  00:00:00     
openstack                                                                                                                              | 2.9 kB  00:00:00     
updates                                                                                                                                | 2.9 kB  00:00:00     
Resolving Dependencies
--> Running transaction check
---> Package mariadb.x86_64 3:10.1.20-2.el7 will be installed
---> Package mariadb-server.x86_64 3:10.1.20-2.el7 will be installed
--> Finished Dependency Resolution
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.

 第四步:启动mariadb

                systemctl start mariadb

                systemctl status mariadb

[root@openstack2 etc]# systemctl status mariadb
● mariadb.service - MariaDB 10.1 database server
   Loaded: loaded (/usr/lib/systemd/system/mariadb.service; disabled; vendor preset: disabled)
   Active: active (running) since Mon 2024-08-26 23:40:03 EDT; 12min ago
  Process: 12864 ExecStartPost=/usr/libexec/mysql-check-upgrade (code=exited, status=0/SUCCESS)
  Process: 12787 ExecStartPre=/usr/libexec/mysql-prepare-db-dir %n (code=exited, status=0/SUCCESS)
  Process: 12764 ExecStartPre=/usr/libexec/mysql-check-socket (code=exited, status=0/SUCCESS)
 Main PID: 12823 (mysqld)
   Status: "Taking your SQL requests now..."
   CGroup: /system.slice/mariadb.service
           └─12823 /usr/libexec/mysqld --basedir=/usr
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.

上面就是mariadb 卸载的全过程,和安装的过程

希望对你有所帮助!