CentOS 7.x 卸载删除MariaDB,重新安装

2022-05-06 20:23:06 浏览数 (1)

###1、卸载

代码语言:javascript复制
[root@node1 ~]# rpm -qa|grep mariadb
mariadb-5.5.56-2.el7.x86_64
mariadb-libs-5.5.56-2.el7.x86_64
mariadb-server-5.5.56-2.el7.x86_64
[root@node1 ~]#
代码语言:javascript复制
[root@node1 ~]# yum remove mariadb
...
Removed:
  mariadb.x86_64 1:5.5.56-2.el7                                                                                                                  

Dependency Removed:
  mariadb-server.x86_64 1:5.5.56-2.el7                                                                                                           

Complete!
[root@node1 ~]#

2、删除遗留目录

代码语言:javascript复制
[root@node1 ~]# ls /etc/my.cnf
/etc/my.cnf
[root@node1 ~]# ll /var/lib/mysql/
total 28700
-rw-rw---- 1 mysql mysql    16384 May  5 10:31 aria_log.00000001
-rw-rw---- 1 mysql mysql       52 May  5 10:31 aria_log_control
-rw-rw---- 1 mysql mysql 18874368 May  5 10:31 ibdata1
-rw-rw---- 1 mysql mysql  5242880 May  5 10:31 ib_logfile0
-rw-rw---- 1 mysql mysql  5242880 Oct  6  2017 ib_logfile1
drwx------ 2 mysql mysql     4096 Oct  6  2017 mysql
drwx------ 2 mysql mysql     4096 Oct  6  2017 performance_schema
[root@node1 ~]#
代码语言:javascript复制
[root@node1 ~]# rm -rf /etc/my.cnf
[root@node1 ~]# rm -rf /var/lib/mysql/

【2021年11月22日更新】 如果没有删除对应的数据目录,重新安装MariaDB后,启动时会出现如下异常

代码语言:javascript复制
Database MariaDB is probably initialized in /var/lib/mysql already, nothing is done.
If this is not the case, make sure the /var/lib/mysql is empty before running mysql-prepare-db-dir.

3、重新安装

代码语言:javascript复制
[root@node1 ~]# yum install -y mariadb mariadb-server
[root@node1 ~]# systemctl start mariadb
[root@node1 ~]# systemctl enable mariadb
[root@node1 ~]# mysql_secure_installation

0 人点赞