I am using Debian Etch and I have following this and tried to write a script like this to auto start mysql server at boot:

#! /bin/sh
# /etc/init.d/blah

# Some things that run always
sudo /etc/init.d/mysql start

I used update-rc.d also, but mysql server don't start at boot, why?


There's no reason for you to write this script. /etc/init.d/mysql is an init(1) script, so just use that:

# update-rc.d mysql defaults

If that doesn't work, you might need to look into the more advanced update-rc.d options. For instance, maybe you are using an uncommon runlevel, and the default runlevels for the provided mysql script don't include that.

If you were actually trying to get something to run on startup which doesn't already provide an init script, you'd need to remove the sudo bit. init scripts run as root already. You actually have to drop permissions if you need your program to run as another user.

  • for some unknown reason this always has stated: insserv: warning: current start runlevel(s) (3) of script 'mysql' overwrites defaults (2 3 4 5). insserv: warning: current stop runlevel(s) (0 1 2 4 5 6) of script 'mysql' overwrites defaults (0 1 6). I had to update-rc.d mysql remove and then do update-rc.d mysql defaults this fixes it. If you want to know which runlevel youre running use who -r – P.Scheit Jun 5 '14 at 6:07

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.