MariaDB를 완전히 제거하기 위해 MariaDB Knowledge Base와 Ubuntu community 설명이 약간 상이합니다.

MariaDB Knowledge Base 설명

MairaDB Knowledge Base에는 "우분투를 사용하는 경우" apt-get 명령을 사용하여 데이터베이스 패키지를 제거하라고 설명이 되어 있습니다.

https://mariadb.com/kb/en/uninstall-or-delete-mariadb-completely-for-re-installation/

$ sudo apt-get purge mariadb-server

You may check which mariadb packages are installed with:

$ sudo dpkg -l | grep mariadb

 

Ubuntu community 설명

이 페이지에서는 apt-get 및 관련 명령을 사용하여 시스템에서 패키지를 제거하는 방법을 설명합니다.

https://help.ubuntu.com/community/AptGet/Howto

 

아래 명령은 설치된 패키지를 제거하고 구성 파일은 그대로 둡니다.

 

apt-get remove <package_name>


아래 명령은 패키지 및 관련 구성 파일을 완전히 제거합니다. ~(home directory를 나타냄) 에 있는 구성 파일은 일반적으로 이 명령의 영향을 받지 않습니다

 

apt-get purge <package_name>

 

아래 명령은 다른 패키지에 의해 설치되어 더 이상 필요하지 않은 패키지를 제거합니다. 

 

apt-get autoremove


이 명령은 설치된 패키지와 종속성을 제거합니다.

apt-get autoremove <package_name>

 

  • While there is no built in way to remove all of your configuration information from your removed packages you can remove all configuration data from every removed package with the following command.

  • 제거된 패키지에서 모든 구성 정보를 제거하는 내장된 방법은 없지만 다음 명령을 사용하여 제거된 모든 패키지에서 모든 구성 데이터를 제거할 수 있습니다.
  • dpkg -l | grep '^rc' | awk '{print $2}' | xargs dpkg --purge

Search commands

 

 

mariadb의 설정 파일을 삭제하기 위해서 purge를 통해 삭제를 해줍니다.

$ sudo apt purge mariadb-*

apt purge명령어는 패키지를 제거하면 구성 파일과 함께 패키지를 삭제합니다. apt remove 명령은 패키지만 제거하지만 구성 파일은 그대로 유지됩니다. 

명령어를 실행하면 최신버전이나 다른 버전을 설치하기 위해서라면 데이터를 보관하라는 메지시지가 나타납니다. 데이터가 존재하고 보관해야 한다면, 별도 백업을 받고 삭제합니다. 화살표 키를 움직여 <Yes>선택하고 엔터키를 칩니다.

그 후 autoremove 명령어를 통해 패키지의 의존성 때문에 설치된 패키지들을 제거해 줍니다. mariadb와 관련되어 설치된 패키지들이 제거됩니다.

 

$ sudo apt autoremove

The following packages will be REMOVED:
  galera-3 libcgi-fast-perl libcgi-pm-perl libconfig-inifiles-perl libdbd-mysql-perl libdbi-perl libencode-locale-perl
  libfcgi-perl libhtml-parser-perl libhtml-tagset-perl libhtml-template-perl libhttp-date-perl libhttp-message-perl
  libio-html-perl liblwp-mediatypes-perl libmysqlclient21 libsnappy1v5 libterm-readkey-perl libtimedate-perl
  liburi-perl mysql-common socat
0 upgraded, 0 newly installed, 22 to remove and 0 not upgraded.
After this operation, 16.2 MB disk space will be freed.

 

mysql 관련 config 파일이 남아 있으니, dpkg 명령어를 사용하여 제거해 줍니다.

dpkg -l | grep mysql

rc  mysql-common                   5.8+1.0.5ubuntu2                      all          MySQL database common files, e.g. /etc/mysql/my.cnf

 

dpkg 예시화면

위처럼 mysql-common 이 보이면

sudo apt purge mysql-common

명령어를 통해 제거해줍니다.

 

그 후 꼭 REBOOT을 해줍니다.

sudo reboot

 

MariaDB 재설치
sudo apt install mariadb-server --fix-missing --fix-broken

<!--  --fix-missing --fix-broken를 사용하여 fetch to fail 에러를 대비합니다. -->

 

성공

오류 없이 정상적으로 잘 설치된 부분을 확인할 수 있습니다.

+ Recent posts