Description:
I just installed MySQL 5.7.11 with the MySQL APT repository, in Ubuntu 14.04 LTS ("Trusty Tahr").
Out-of-the-box, the included init script reports a failure to start, when, in fact, the MySQL starts just fine.
The output looks like this:
-----------------------------------------------
root@ubuntu-vm:~# service mysql start
.................................................................................................................................................................................... * MySQL Community Server 5.7.11 did not start. Please check logs for more details.
-----------------------------------------------
The problem appears to be that the init script's get_running() function expects and looks for the PID file to exist in a location that does not match where the PID file is being created.
On my system, with all MySQL defaults intact, the PID file is created in MySQL's data directory, in the file /var/lib/mysql/$(hostname).pid.
Yet, the init script is looking for the file in /var/run/mysqld/mysqld.pid, via the following Bash function call (I've substituted the interpreted values for $1 and $2, for clarity):
my_print_defaults "mysqld_safe" | sed -n "s/^--pid-file=//p" | tail -n 1
which returns /var/run/mysqld/mysqld.pid.
It's not clear why/how the PID file is being created in MySQL's data directory.
If I replace the line that sets the $PIDFILE,
PIDFILE=$(get_mysql_option mysqld_safe pid-file "")
with
PIDFILE="$MYSQLDATA/$(hostname).pid"
the init script starts the server immediately and without issue.
But, unfortunately, this is not a complete fix, because attempts to *stop* the server with the init script fail with an incorrect message that the server is already stopped, when, in fact, it is still running:
# service mysql stop
* MySQL Community Server 5.7.11 is already stopped
The only way I can get this init script to start and stop MySQL successfully is to hard-code the $MYSQLDATA portion of the PID file path, on the first line of the get_running() function, e.g.:
PIDFILE=/var/lib/mysql/$(hostname).pid
At this stage, I'm not sure why using PIDFILE="$MYSQLDATA/$(hostname).pid" works only for starting the server and not stopping it.
Further attention should be dedicated to ironing-out the problems with this init script on Ubuntu.
Thank you.
How to repeat:
Install cited MySQL version on cited OS version and attempt to start the server using the init script:
# service mysql start
.................................................................................................................................................................................... * MySQL Community Server 5.7.11 did not start. Please check logs for more details.
-----------------------------------------------
Suggested fix:
Debug the fact that the get_running() function in the script returns erroneous values.