I was trying to install mysql-server and while trying to set a password I messed up the debian.cnf file and then deleted /etc/mysql hoping that dpkg-reconfigure would recreate it.

Now dpkg-reconfigure is giving an error regarding missing cnf files in /etc/mysql

Tried reinstalling mysql-server itself but the post-install script is giving errors.

I've also tried reinstalling libmysqldev, libmysql20 and mysql-common. No luck.

Which package should I reinstall to create the /etc/mysql and its contents

If I remember correctly the directory contains my.cnf, debian.cnf, conf.d and a couple other files. I'm running Ubuntu 18.04

  • I guess this is a duplicate question since unix.stackexchange.com/questions/27549/… has the answer that I'm looking for.
    – vishless
    Jun 26, 2018 at 2:35
  • You might try running dpkg -S /etc/mysql (although this may miss files that are created on the fly by pre/post install scripts, rather than being provided by a package directly) Jun 26, 2018 at 2:44

1 Answer 1


The contents of /etc/mysql are created by mysql-server-5.7’s postinst (replace “5.7” with whichever version you have). You should try running

sudo dpkg-reconfigure mysql-server-5.7

and fixing any errors which occur then.

How can I completely reinstall mysql? explains how to reinstall MySQL completely. Do note however that deleting /var/lib/mysql will delete any database which you’ve created.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.