When doing an installation of a specific version of MySQL on your CentOS machine, you may get errors caused by the previous MySQL that had been installed earlier; probably a different version.
When that happens, it is recommended that you remove MySQL completely from your system and then do a fresh installation with the specific version of your choice.
Below is the procedure to remove MySQL from your CentOS system..
NB: Ensure that you do not have any databases that are running.
- Uninstalling MySQL
Log in as root and uninstall all the MySQL packages
# yum remove mysql mysql-server
- Remove MySQL Directory
By default, the MySQL data directory is /var/lib/mysql
This directory needs to be removed as well. We recommend you do a backup of the current directory and remove it.
# mv /var/lib/mysql /var/lib/mysql_old
- Remove other mysql packages
Run the following command to ensure that all MySQL packages are removed.
# rpm -qa | grep mysql
Then remove the specific MySQL package should you find it.
Once this is done, you can now go ahead and do a clean install of MySQL.
Very important. Was trying t reinstall without removing old mysql directory. mysql couldn’t even start with traces of old files.