Restore MySQL config file

I have installed mysql-server on my laptop running Debian back in awhile. For that reason, I forgot the root password. Just recently, I need to use MySQL server for one of my assignments. So, I was playing around in /etc/mysql/ directory hoping that I could get rid of the server and then reinstall it. The commands apt-get remove mysql-server didn’t seem to remove files/directories related to MySQL. Then, I decided to delete the /etc/mysql/ manually.

After I reinstalled mysql-server, a few config files ,contained in /etc/mysql direcotry, were never reinstalled. As always, I turned to Google for helps. With a few different combination of keywords, I found a solution to problem.

First, let’s completely remove mysql-server:

$ sudo apt-get remove --purge mysql-common
$ sudo apt-get remove mysql-server

Then reinstall mysql-server again:

$ sudo apt-get install mysql-common mysql-server

This time, I carefully chose a root password which was easy enough to remember. And voilla, it worked!

$ mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 12
Server version: 5.0.45-Debian_1-log Debian etch distribution

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql>

5 thoughts on “Restore MySQL config file

Leave a reply to Florian Westreicher Cancel reply