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.
コメント