top of page

How to Remove MySQL Completely from Linux

As a DBA sometimes we get the task to remove MySQL installation from Server. We have to uninstall MySQL completely from the system and erase all settings of old install.

First, we need to Check that mysql is installed and server is running or stop.

Check the service is running or not.

[root@DBATrainings ~]# ps -ef | grep mysql

[root@DBATrainings ~]# sudo systemctl status mysqld

Before going to uninstall or remove the MySQL we need to stop MySQL Service.

Stop mysql service

[root@DBATrainings ~]# sudo service mysqld stop

Uninstall MySQL Packages installed on your server.

[root@DBATrainings ~]# sudo yum remove mysql mysql-server

Remove MySQL Directory from operating system.

Now we are ready 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 the system

[root@DBATrainings ~]# ls /var/lib/mysql/

[root@DBATrainings ~]# rm -rf /var/lib/mysql/

Now let me check and assure the file is not available.

[root@DBATrainings ~]# ls /var/lib/mysql/

Final step we need to remove the configuration file as well.

[root@DBATrainings ~]# sudo rm -rf /etc/mysql/

[root@DBATrainings ~]# sudo rm -rf /etc/my.cnf

[root@DBATrainings ~]# sudo rm -rf /etc/usr/share/mysql

[root@DBATrainings ~]# sudo rm -rf /etc/usr/share/mysql/charsets

For More Details, you can reach us using the below link. 


471 views0 comments

Recent Posts

See All

How to Connect MySQL Without Root Password.

Many times, I got the question from my colleague or training participants, how to login MySQL if I forgot the password. I have explained the process in many times to them but thought to write this sce

Step by Step Oracle 21c Installation on Linux

Oracle Database 21c is the first Oracle database release with CDB-only architecture. Oracle 20c was announced only CDB architecture but it was not release for on premises. Only for Cloud. That's why i


bottom of page