summaryrefslogtreecommitdiff
path: root/mariadb-check-upgrade.sh
diff options
context:
space:
mode:
authorCoprDistGit <infra@openeuler.org>2023-08-20 10:47:28 +0000
committerCoprDistGit <infra@openeuler.org>2023-08-20 10:47:28 +0000
commitf0b08fdbf2ac1c6bbbeba9a96babfae8277ed3ef (patch)
treeeeb9a49118267c48caeefb2bbfa3f9f8ba1e3658 /mariadb-check-upgrade.sh
parentde830acca23eae53159e3721fc648ce8a86427b7 (diff)
Diffstat (limited to 'mariadb-check-upgrade.sh')
-rw-r--r--mariadb-check-upgrade.sh39
1 files changed, 39 insertions, 0 deletions
diff --git a/mariadb-check-upgrade.sh b/mariadb-check-upgrade.sh
new file mode 100644
index 0000000..740e4be
--- /dev/null
+++ b/mariadb-check-upgrade.sh
@@ -0,0 +1,39 @@
+#!/bin/sh
+
+source "`dirname ${BASH_SOURCE[0]}`/mariadb-scripts-common"
+
+upgrade_info_file="$datadir/mysql_upgrade_info"
+version=0
+# get version as integer from mysql_upgrade_info file
+if [ -f "$upgrade_info_file" ] && [ -r "$upgrade_info_file" ] ; then
+ version_major=$(cat "$upgrade_info_file" | head -n 1 | sed -e 's/\([0-9]*\)\.\([0-9]*\)\..*$/\1/')
+ version_minor=$(cat "$upgrade_info_file" | head -n 1 | sed -e 's/\([0-9]*\)\.\([0-9]*\)\..*$/\2/')
+ if [[ $version_major =~ ^[0-9]+$ ]] && [[ $version_minor =~ ^[0-9]+$ ]] ; then
+ version=$((version_major*100+version_minor))
+ fi
+fi
+
+# compute current version as integer
+thisversion=$((10*100+5))
+
+# provide warning in cases we should run mysql_upgrade
+if [ $version -ne $thisversion ] ; then
+
+ # give extra warning if some version seems to be skipped
+ if [ $version -gt 0 ] && [ $version -lt 505 ] ; then
+ 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
+ fi
+
+ cat <<EOF >&2
+The datadir located at $datadir needs to be upgraded using 'mariadb-upgrade' tool. This can be done using the following steps:
+
+ 1. Back-up your data before with 'mariadb-upgrade'
+ 2. Start the database daemon using 'systemctl start mariadb.service'
+ 3. Run 'mariadb-upgrade' with a database user that has sufficient privileges
+
+Read more about 'mariadb-upgrade' usage at:
+https://mariadb.com/kb/en/mysql_upgrade/
+EOF
+fi
+
+exit 0