diff options
| author | Lars Tangvald <lars.tangvald@oracle.com> | 2016-04-25 09:32:47 (GMT) |
|---|---|---|
| committer | Robie Basak <robie.basak@canonical.com> | 2016-05-24 14:34:40 (GMT) |
| commit | 7897042ea6c65aeb608fb28b4b54639d3dbf3352 (patch) | |
| tree | 6cbd0f69485e95809448ae19757dcfcaf10ad421 | |
| parent | 62becc5d03473d5b7b46178c034157d2621813d3 (diff) | |
Try to fail postinst with useful error message if server can't start
Running mysqld --verbose --help --innodb-read-only 2>&1 > /dev/null will
output any errors that would prevent the server from starting normally. We
use it to detect issues such as invalid config options so we can fail faster
and give a more useful error message
| -rwxr-xr-x | debian/mysql-server-5.7.postinst | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/debian/mysql-server-5.7.postinst b/debian/mysql-server-5.7.postinst index 93cc753..508357f 100755 --- a/debian/mysql-server-5.7.postinst +++ b/debian/mysql-server-5.7.postinst @@ -45,6 +45,24 @@ invoke() { fi } +# Check if server is able to start. If it fails we abort early and refer +# the user to a wiki page with solutions for common configuration problems. +test_mysqld_startup() { + # mysqld --verbose --help will output a full listing of settings and plugins. + # To do so it needs to initialize the database, so it can be used as a test + # for whether or not the server can start. We redirect stdout to /dev/null so + # only the error messages are left. + result=0 + output=$(mysqld --verbose --help --innodb-read-only 2>&1 > /dev/null) || result=$? + if [ ! "$result" = "0" ]; then + echo "ERROR: Unable to start MySQL server:" >&2 + echo "$output" >&2 + echo "Please take a look at https://wiki.debian.org/Teams/MySQL/FAQ for tips on fixing common upgrade issues." >&2 + echo "Once the problem is resolved, run apt-get --fix-broken install to retry." >&2 + fi + return $result +} + # Check if there is passwordless root login test_mysql_access() { mysql --no-defaults -u root -h localhost </dev/null >/dev/null 2>&1 @@ -137,6 +155,8 @@ case "$1" in # data directory and then somewhen gets purged by the admin. db_set mysql-server/postrm_remove_database false || true + # Sanity check to make sure the server can start + test_mysqld_startup ## On every reconfiguration the maintenance user is recreated. # |
