I've occasionally lost my config file "/etc/mysql/my.cnf", and want to restore it. The file belongs to package mysql-common
which is needed for some vital functionality so I can't just purge && install
it: the dependencies would be also uninstalled (or if I can ignore them temporarily, they won't be working).
Is there a way to restore the config file from a package without un-ar
-ing the package file?
dpkg-reconfigure mysql-common
did not restore it.
dpkg -i --force-confmiss mysql-common.deb
will recreate any missing configuration files, ie/etc/mysql/my.cnf
in your case.None of the above worked for me - maybe outdated - anyway, I found this solution:
In Debian Squeeze — at least —, we also can do it this way, after
su
— orsudo
for Ubuntu —This will care for the dependencies of
mysql-server
and reset all the missing conf files of the lot, includingmysql-common
. Conflicting (remaining) files will be prompted out to be kept or reset.Unfortunately, there is a bug in aptitude, and
will not work. So we have to do it one by one with
This will remove any config file, original or modified, but custom files will be preserved, with an onscreen message. Note, by the way, that
dpkg
also recognizes--force-confnew
and--force-confold
options.To get
mysql-server
dependencies' list print on screen :You can find default mysql config files in
/usr/share/doc/mysql-server-5.0/examples/
or similar. That may be all that you need unless you have some really special/esoteric configurations enabled.In my
/etc/mysql/
directory, I have amy.cnf.orig
file which contains the original contents ofmy.cnf
.I'm not sure where
/etc/mysql/my.cnf.orig
came from - that is, whether I created it, or the installation of mysql did it. I remember checking at one time that it was exactly the same asmy.cnf
If you have such a thing, and no
my.cnf
you can copy one to the other.In any case, it's a simple text file of 3897 bytes and you could copy and paste from a generic Mysql configuration file.
It will be a good idea once you restore your
/etc/mysql/my.cnf
to make a copy so you can restore it easily in future.You need to reinstall mysql-common with this command:
apt-get install --reinstall mysql-common
It appears some of the other solutions won't work if the configuration files of the package are managed with
ucf
.In this case you can use :