Ubuntu – Recover package configuration file using apt-get

Previously i have setup a server with Nginx and MariaDB.
Run Drupal 7 in Nginx

But there is one problem in this setup. I cannot restart the MariaDB service. Whenever it is down, i have to restart the server instance.

At first, i thought the failure is caused by the modification of the /etc/mysql/my.cnf. So i try to restore the original my.cnf. The following solution helps you to restore the default package configuration file.

1. Find out the package of that default file by dpkg -S.

dpkg -S my.cnf


2. Backup the wrongly edited config file.

mv /etc/mysql/my.cnf /etc/mysql/my.cnf.bak


3. Restore the file by the following command. (Need sudo for root privilege)

apt-get -o Dpkg::Options::="--force-confmiss" install --reinstall mysql-common


4. If everything works fine, you will get the following output.

Configuration file '/etc/mysql/my.cnf', does not exist on system. 
Installing new config file as you requested.


Unfortunately, the MariaDB problem is not related to the my.cnf settings. Anyway, hope this solution could help if you have broken a config file.

Done =)

Reference: Ask Ubuntu – How can I restore configuration files?


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.