Posts: 35
antix_forum_account
Joined: 01 Feb 2013
#1
Dear Forum,

I've been tweaking my Apache/PHP/... setup.

In the process, I made the following mistake:

Code: Select all

sudo rm -rf /etc/apache2 /etc/mysql /etc/php5/
This is giving me some headaches. Among other things, I'm getting thefollowing messages when starting mysql...

Code: Select all

~% sudo service mysql start
Starting MySQL database server: mysqld ..
/etc/init.d/mysql: line 120: /etc/mysql/debian-start: No such file or directory
How can I recover the lost /etc/mysql directory?

Thanks!!! ☺
Posts: 1,308
BitJam
Joined: 31 Aug 2009
#2
I did a
========= SCRAPER REMOVED AN EMBEDDED LINK HERE ===========
url was:"https://encrypted.google.com/search?q=recover+the+lost+/etc/mysql+directory"
linktext was:"Google(recover the lost /etc/mysql directory)"
====================================
and the
========= SCRAPER REMOVED AN EMBEDDED LINK HERE ===========
url was:"https://answers.launchpad.net/ubuntu/+question/24"
linktext was:"first hit"
====================================
had the answer:
found how to fix it, removing it with the --purge:

sudo apt-get remove --purge mysql-server
and
sudo apt-get install mysql-server
Posts: 35
antix_forum_account
Joined: 01 Feb 2013
#3
Dear BitJam, thanks for your reply!!!! ☺

No, alas this doesn't work

Code: Select all

~% sudo apt-get remove --purge mysql-server
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
  libaio1 mysql-server-5.5 mysql-server-core-5.5
Use 'apt-get autoremove' to remove them.
The following packages will be REMOVED:
  mysql-server*
0 upgraded, 0 newly installed, 1 to remove and 1 not upgraded.
After this operation, 130 kB disk space will be freed.
Do you want to continue [Y/n]?
(Reading database ... 82142 files and directories currently installed.)
Removing mysql-server ...
~% sudo apt-get install mysql-server
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
  mysql-server
0 upgraded, 1 newly installed, 0 to remove and 1 not upgraded.
Need to get 0 B/83.6 kB of archives.
After this operation, 130 kB of additional disk space will be used.
Selecting previously unselected package mysql-server.
(Reading database ... 82138 files and directories currently installed.)
Unpacking mysql-server (from .../mysql-server_5.5.31+dfsg-0+wheezy1_all.deb) ...
Setting up mysql-server (5.5.31+dfsg-0+wheezy1) ...
~% sudo service mysql start
Starting MySQL database server: mysqld ..
/etc/init.d/mysql: line 120: /etc/mysql/debian-start: No such file or directory
~% 
I looked around your search terms, and tried this:
========= SCRAPER REMOVED AN EMBEDDED LINK HERE ===========
url was:"http://serverfault.com/questions/82801/linux-how-to-restore-config-file-using-apt-get-aptitude/82817#82817"
linktext was:"http://serverfault.com/questions/82801/ ... 2817#82817"
====================================


It didn't work either, see transcript below. Any suggestions? ☺

Code: Select all

~% sudo dpkg --force-confmiss -i /var/cache/apt/archives/mysql-common_5.5.3*.deb
dpkg: warning: downgrading mysql-common from 5.5.31+dfsg-1 to 5.5.30+dfsg-1.1
(Reading database ... 82142 files and directories currently installed.)
Preparing to replace mysql-common 5.5.31+dfsg-1 (using .../mysql-common_5.5.30+dfsg-1.1_all.deb) ...
Unpacking replacement mysql-common ...
Preparing to replace mysql-common 5.5.30+dfsg-1.1 (using .../mysql-common_5.5.31+dfsg-0+wheezy1_all.deb) ...
Unpacking replacement mysql-common ...
Preparing to replace mysql-common 5.5.31+dfsg-0+wheezy1 (using .../mysql-common_5.5.31+dfsg-1_all.deb) ...
Unpacking replacement mysql-common ...
More than one copy of package mysql-common has been unpacked
 in this run !  Only configuring it once.
More than one copy of package mysql-common has been unpacked
 in this run !  Only configuring it once.
Setting up mysql-common (5.5.31+dfsg-1) ...
~% sudo service mysql start
Starting MySQL database server: mysqld ..
/etc/init.d/mysql: line 120: /etc/mysql/debian-start: No such file or directory
~%
Posts: 1,308
BitJam
Joined: 31 Aug 2009
#4
I Googled(/etc/mysql/debian-start no such file or directory) and found that this is certainly not an uncommon problem.


========= SCRAPER REMOVED AN EMBEDDED LINK HERE ===========
url was:"http://fixunix.com/ubuntu/371589-mysql-etc-init-d-mysql-line-122-error.html"
linktext was:"Here"
====================================
someone fixed it with:

Code: Select all

sudo cp /dev/null /etc/mysql/debian-start
sudo chmod +x /etc/mysql/debian-star
sudo dpkg --configure -a
but later they were warned to get a real copy of the file. One is posted there but it is from 2008. There is a slight variation
========= SCRAPER REMOVED AN EMBEDDED LINK HERE ===========
url was:"https://answers.launchpad.net/ubuntu/+question/24"
linktext was:"here"
====================================
:

Code: Select all

touch /etc/mysql/debian-start
chown mysql:mysql /etc/mysql/debian-start
chmod ug+x /etc/mysql/debian-start
There are also many variations of the purge approach. Finally,
========= SCRAPER REMOVED AN EMBEDDED LINK HERE ===========
url was:"http://compgroups.net/comp.os.linux.misc/problem-reinstalling-mysql/567411"
linktext was:"here"
====================================
is a suggestion to use the --reinstall option:

Code: Select all

apt-get install --reinstall mysql-server
If none of this brings you joy then can will try to install mysql-server and post a copy of the missing file.
Posts: 1,062
Dave
Joined: 20 Jan 2010
#5
You could take the MySQL-server package from /var/cache/apt/packages and manually extract it (dpkg -x I think), then copy the /etc/* folders over. If it is not there check for the default configuration files in /usr/share/mysql iirc, and copy those files to etc.
Posts: 1,308
BitJam
Joined: 31 Aug 2009
#6
Great idea Dave! Here is debian-start from mysql-server-5.5_5.5.31+dfsg-0+wheezy1_amd64.deb:

Code: Select all

#!/bin/bash
#
# This script is executed by"/etc/init.d/mysql" on every (re)start.
# 
# Changes to this file will be preserved when updating the Debian package.
#

source /usr/share/mysql/debian-start.inc.sh

MYSQL="/usr/bin/mysql --defaults-file=/etc/mysql/debian.cnf"
MYADMIN="/usr/bin/mysqladmin --defaults-file=/etc/mysql/debian.cnf"
MYUPGRADE="/usr/bin/mysql_upgrade --defaults-extra-file=/etc/mysql/debian.cnf"
MYCHECK="/usr/bin/mysqlcheck --defaults-file=/etc/mysql/debian.cnf"
MYCHECK_SUBJECT="WARNING: mysqlcheck has found corrupt tables"
MYCHECK_PARAMS="--all-databases --fast --silent"
MYCHECK_RCPT="root"

# The following commands should be run when the server is up but in background
# where they do not block the server start and in one shell instance so that
# they run sequentially. They are supposed not to echo anything to stdout.
# If you want to disable the check for crashed tables comment
#"check_for_crashed_tables" out.  
# (There may be no output to stdout inside the background process!)
echo"Checking for tables which need an upgrade, are corrupt or were"
echo"not closed cleanly."
(
  upgrade_system_tables_if_necessary;
  check_root_accounts;
  check_for_crashed_tables;
) >&2 &

exit 0
You will still need to:

Code: Select all

chmod a+x /etc/mysql/debian-start
chown mysql:mysql /etc/mysql/debian-start
chmod ug+x /etc/mysql/debian-start
I'm not certain the chmod is needed but I don't think it will hurt.
Posts: 35
antix_forum_account
Joined: 01 Feb 2013
#7
yeah! This works ☺

Thank you BitJam and Dave...

I copied over two files from the extract of the deb that I found at /var/cache/apt/archives/mysql-server-5.5_5.5.31+dfsg-0+wheezy1_i386.deb

Code: Select all

~/deb/etc/mysql% sudo cp debian-start /etc/mysql
~/deb/etc/mysql% sudo cp conf.d/mysqld_safe_syslog.cnf /etc/mysql/conf.d
Then I"re-installed"

Code: Select all

sudo aptitude purge mysql-server mysql-client
sudo aptitude install mysql-server mysql-client
Now I don't get the /etc/mysql/debian-start: No such file or directory message when starting MySQL. This brings joy ☺

By now I don't have a record of the past contents of /etc/mysql. fwiw these are its contents at the moment

Code: Select all

/etc/mysql% find .
.
./debian-start
./debian.cnf
./my.cnf
./conf.d
./conf.d/.keepme
./conf.d/mysqld_safe_syslog.cnf