Uninstalling MySql :

sudo apt-get purge mysql-server mysql-client mysql-common mysql-server-core-5.5 mysql-client-core-5.5
sudo rm -rf /etc/mysql /var/lib/mysql
sudo apt-get autoremove
sudo apt-get autoclean

Installation:

sudo apt-get update
sudo apt-get install mysql-server

Note:- Incase you encounter an ‘error:alternative path /etc/mysql/mysql.cnf’ then purge the unconfigured mysql using the

command:’sudo apt-get remove –purge mysql-\*’

& reinstall with the following command below

command:’sudo apt-get install mysql-server mysql-client’

Note: If mysql throws error “Access denied for user ‘root’@’localhost’ ” change the root user password by the following command

  • ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';
  • Where ‘password’ is the new password for the root user.