Blame SOURCES/mysql-check-upgrade.sh

80384c
#!/bin/sh
80384c
80384c
source "`dirname ${BASH_SOURCE[0]}`/mysql-scripts-common"
80384c
80384c
upgrade_info_file="$datadir/mysql_upgrade_info"
80384c
version=0
80384c
# get version as integer from mysql_upgrade_info file
80384c
if [ -f "$upgrade_info_file" ] && [ -r "$upgrade_info_file" ] ; then
80384c
    version_major=$(cat "$upgrade_info_file" | head -n 1 | sed -e 's/\([0-9]*\)\.\([0-9]*\)\..*$/\1/')
80384c
    version_minor=$(cat "$upgrade_info_file" | head -n 1 | sed -e 's/\([0-9]*\)\.\([0-9]*\)\..*$/\2/')
80384c
    if [[ $version_major =~ ^[0-9]+$ ]] && [[ $version_minor =~ ^[0-9]+$ ]] ; then
80384c
        version=$((version_major*100+version_minor))
80384c
    fi
80384c
fi
80384c
80384c
# compute current version as integer
80384c
thisversion=$((@MAJOR_VERSION@*100+@MINOR_VERSION@))
80384c
80384c
# provide warning in cases we should run mysql_upgrade
80384c
if [ $version -ne $thisversion ] ; then
80384c
80384c
    # give extra warning if some version seems to be skipped
80384c
    if [ $version -gt 0 ] && [ $version -lt 505 ] ; then
80384c
        echo "The datadir located at $datadir seems to be older than of a version 5.5. Please, mind that as a general rule, to upgrade from one release series to another, go to the next series rather than skipping a series." >&2
80384c
    fi
80384c
80384c
    cat <<EOF >&2
80384c
The datadir located at $datadir needs to be upgraded using 'mysql_upgrade' tool. This can be done using the following steps:
80384c
80384c
  1. Back-up your data before with 'mysql_upgrade'
80384c
  2. Start the database daemon using 'service @DAEMON_NAME@ start'
80384c
  3. Run 'mysql_upgrade' with a database user that has sufficient privileges
80384c
80384c
Read more about 'mysql_upgrade' usage at:
80384c
http://dev.mysql.com/doc/refman/5.6/en/mysql-upgrade.html
80384c
EOF
80384c
fi
80384c
80384c
exit 0