mySQL failing to start on boot

edge_e's picture

Forums: 

Hi,
Since making changes to bind mySQL to my network address to allow access from other machines, it fails to start on boot.
I believe this is because mySQL is attempting to start before the network is configured.
Here's the entries in syslog

May 13 19:15:04 www mysqld: 120513 19:15:04  InnoDB: Started; log sequence number 0 44233
May 13 19:15:04 www mysqld: 120513 19:15:04 [ERROR] Can't start server: Bind on TCP/IP port: Cannot assign requested address
May 13 19:15:04 www mysqld: 120513 19:15:04 [ERROR] Do you already have another mysqld server running on port: 3306 ?
May 13 19:15:04 www mysqld: 120513 19:15:04 [ERROR] Aborting
May 13 19:15:04 www mysqld:
May 13 19:15:04 www mysqld: 120513 19:15:04  InnoDB: Starting shutdown...
May 13 19:15:04 www NetworkManager[1838]: <info> Activation (eth0) Stage 5 of 5 (IP Configure Commit) scheduled...
May 13 19:15:04 www NetworkManager[1838]: <info> Activation (eth0) Stage 4 of 5 (IP4 Configure Get) complete.
May 13 19:15:04 www NetworkManager[1838]: <info> Activation (eth0) Stage 5 of 5 (IP Configure Commit) started...
May 13 19:15:05 www NetworkManager[1838]: <info> (eth0): device state change: 7 -> 8 (reason 0)
May 13 19:15:05 www NetworkManager[1838]: <info> Policy set 'Auto eth0' (eth0) as default for IPv4 routing and DNS.
May 13 19:15:05 www NetworkManager[1838]: <info> Activation (eth0) successful, device activated.
May 13 19:15:05 www NetworkManager[1838]: <info> Activation (eth0) Stage 5 of 5 (IP Configure Commit) complete.

How can I make mySQL wait for the network?
Thanks

Re: mySQL failing to start on boot

IntnsRed's picture

Do you have another MySQL running or something accessing port 3306?

What sort of network connection do you have? MySQL should start normally by default.

Try this to ensure it's what you're thinking:

1) Do a "/etc/init.d/mysql stop" to make sure MySQL is down.

2) Ensure your network is up and running okay.

3) Then do a "/etc/init.d/mysql start" to bring MySQL up.

4) Check to see if it's running and its logs for any errors.

Re: mySQL failing to start on boot

edge_e's picture

Hi thanks for the reply,

mySQL starts and stops just fine when the init scripts are run manually, It's just on boot that it fails.
syslog appears to show the network coming up after mySQL reports failure.
The network connection is wired and has a manually assigned IP address, It was DHCP on a reserved address but i thought this might be part of the problem.
I attempted to move mysql to later in the boot sequence using update-rc.d but that gave me a message
update-rc.d: using dependency based boot sequencing

which is why I'm here asking for help.

Re: mySQL failing to start on boot

IntnsRed's picture

Strange. It seems the networking is not coming up properly or quickly enough, which with a static IP address seems really odd.

If it's just a matter of a delay that's needed, you could easily stick a "sleep 1m" statement in the /etc/init.d/mysql script after the case...start section, down about line 100 or so. But that's a bad tactic not only because you shouldn't have to do that but because future MySQL changes will overwrite the change. However, it might be worth doing that for test purposes to see if that's all that is needed -- the delay for networking when it's started.

> The network connection is wired and has a manually assigned IP address,
> It was DHCP on a reserved address but i thought this might be part of the problem.

That's interesting. Are all the references to the DHCP settings removed from whatever was configuring the network that way? With no DHCP server available, if the networking is trying fruitlessly to find a DHCP server, that DHCP server search/network timeout could be the cause of the delay that's needed for the static networking to then come up properly and MySQL to find the network.

Re: mySQL failing to start on boot

edge_e's picture

Tonight it booted fine ???
The only thing I changed last night was adding name servers to networkmanager. Don't see why that would make a difference, maybe it's just luck.
I'll post back in a few days.

Re: mySQL failing to start on boot

edge_e's picture

OK, mySQL is starting on boot about 50% of the time.
I'll fix it by adding a sleep statement for now but there's got to be a better way?

Same problem here except the

aelfric's picture

Same problem here except the sleep 1 did not fix it for me. Instead add network-manager to the Should-Start line in /etc/init.d/mysql then as root run 'insserv mysql'. This will ensure that mysql is not started until after NetworkManager has run and all dependencies of mysql are also moved later as well. This works for me with a DHCP address.

Re: insserv

edge_e's picture

Thanks for that, I knew there'd be a way to do it properly