Completely uninstall and reinstall mysql in Ubuntu

Uninstall mysql and delete cache

					sudo apt purge mysql-*
sudo rm -rf /etc/mysql/ /var/lib/mysql
sudo apt autoremove
sudo apt autoclean


					sudo apt-get install mysql-server -y

Check if the mysql service starts successfully

					sudo netstat -tap | grep mysql

The output should look like this

If mysql is not started, run the start command

					sudo service mysql start

Warning: cannot change directory to xxx...

If need password for root user

In special cases, you need to enter the root password. However, we first logged in and did not have the root user password

1. Get password for default user

					sudo cat /etc/mysql/debian.cnf

2. Log in with the default user and password found above

					mysql -udebian-sys-maint -pRkqm8f6NHv1CYsrB

Leave a Comment

Your email address will not be published.