How to clean up mysql installation on centos / Amazon Linux ? I want to make simpler servers available for my Charming Customers

Views: 643

Some time we faces issues with MySQL installation on Linux machine. If we simply remove MySQL packages and re-install doesn’t fixes the issue, in that case old settings may still exists on server which again affects new install. In that case first uninstall MySQL completely from system and erase all settings of old install. To do the same follow the below settings.

Note: Please do not use below steps if MySQL have any running databases.

Step 1: Uninstall MySQL Packages

First uninstall all the MySQL packages installed on your server

 # yum remove mysql mysql-server
Step 2: Romove MySQL Directory

Now we need to remove MySQL data directory from system which by default exists at /var/lib/mysql. If you didn’t find this, It may be changed to some other place, which you can find in my.cnf file with variable datadir. Delete the /var/lib/mysql directory from system but we prefer to rename it to keep a backup of existing files.

 # mv /var/lib/mysql /var/lib/mysql_old_backup
Step 3: Install MySQL Packages Again

After removing MySQL completely, install it again using yum package manager, It will re create mysql directory under /var/lib/.

# yum install mysql mysql-server

After completing above three steps, now you have a fresh MySQL install on your system with new settings.

How To Remove MySQL Completely from Your Linux System


mysql does not exist anymore but when i run yum remove mysql it says that the package is available but not marked for installation, i cannot install new mysql because of that, I need to completely delete everything related to it before installing new one, i do not have tables created so don’t need to backup anything i tried to use the yum plugin yum-remove-with-leaves didn’t work and didn’t find any guide to install it properly, anyway i read on forums that it’s buggy and should not be installed so I’m searching for other ways to remove mysql completely

and can i do it using sftp?


the output of rpm -qa | grep mysql is



I tried

yum remove mysql
yum remove mysql-server
yum clean all

and it doesn’t seem to fix it.

When I run yum install mysql mysql-server or yum install mysql or yum install install mysql-server i would get this

enter image description here

4 Answers

yum remove mysql55-libs and try again.

Besides, I saw you used a lot of repos: atomic, dag, epel, rpmforge, livna, …, it may be the cause of conflicting. In my opinion, atomic and (rpmforge or epel) are enough.

  1. Execute the following command :
    # rpm -qa | grep mysql

    It will list all installed mysql packages on your system. Eg: mysql-libs-5.1.73-3.el6_5.x86_64

  2. now execute the command:
    # yum remove <name displayed in above step-1>

    Eg: yum remove mysql-libs-5.1.73-3.el6_5.x86_64

Try this:

    yum clean all
    yum install mysql

you may have somehow installed mariadb when you thought it was installing mysql.

[root@localhost data_decrypt]# rpm -qa | grep maria


Source: How to clean up mysql installation on centos – Server Fault

Leave a Reply