Fix Zoneminder Failed to Start Automatically on Boot

See log file to see the problem:

cat /var/log/syslog | tr -d '\0' | grep "Failed to start" -A 10 -B 10

If you see this line below, then we may have solution:

Can't connect to local MySQL server through socket

Ubuntu 16.04.01 LTS is using systemd
Use this command to see your ubuntu version:

lsb_release -a

Zoneminder service described in this file:

/etc/systemd/system/multi-user.target.wants/zoneminder.service

By default it is remarked:

#Requires=mysql.service

Remove the remark so it waits mysql before starts:

Requires=mysql.service

For Ubuntu 14.04 add sleep command in /etc/init.d/zoneminder after start() line, so it looks like below:

start() {
sleep 15 #wait for mysql
echo -n "Starting $prog: "

Source:
– https://forums.zoneminder.com/viewtopic.php?t=23630
– https://wiki.zoneminder.com/Ubuntu_Server_14.04_64-bit_with_Zoneminder_1.28.0_the_easy_way