Skip to content
Snippets Groups Projects
Commit 3919860b authored by Otto Kekäläinen's avatar Otto Kekäläinen
Browse files

Automate renaming MySQL auth_socket correctly in mysql_upgrade (Closes: #926231)

Don't run any excess mysqld processes in bootstrap mode, but let mysql_upgrade
take care of all database conversions and upgrade tricks. We can never have
all of mysql_upgrade contents as part of the mariadb-server postinstall script,
so don't even attempt it. A better approach is to patch mysql_upgrade is something
extra is needed.

Merge suitable parts of upstream commit
https://github.com/MariaDB/server/commit/7f6d88944c8afdcba12677840db8bc4e81cbe0db

Also drop legacy user table Password column fix dropped in upstream commit
https://github.com/MariaDB/server/commit/60ad33984090af2262d17232ceab1c1c9231fd24

Re-implement plugin rename similar to as done in upstream commit
https://github.com/mariadb/server/commit/fdfdea40f1b9d029de59131f54096c1b044ffdfa
parent b1c1bf91
No related branches found
No related tags found
No related merge requests found
......@@ -503,7 +503,9 @@ mysql-5.7 to mariadb-10.3 upgrade:
# Verify installation of MySQL from Sid
- dpkg -l | grep -iE 'maria|mysql|galera' || true # List installed
- service mysql status
- mysql --skip-column-names -e "select @@version, @@version_comment"
- mysql --skip-column-names -e "SELECT @@version, @@version_comment"
- mysql -e "SELECT Host,User,plugin,authentication_string FROM user;" mysql
- mysql -e "SELECT * FROM plugin;" mysql
- echo 'SHOW DATABASES;' | mysql
# Install MariaDB built in this commit
- apt-get install -y ./*.deb || true # Allow to proceed so debug artifacts get collected
......@@ -515,7 +517,10 @@ mysql-5.7 to mariadb-10.3 upgrade:
- find /var/lib/mysql -ls > debug/var-lib-mysql.list
- cp -ra /etc/mysql debug/etc-mysql
- cp -ra /var/log/mysql debug/var-log-mysql
- mariadb --skip-column-names -e "select @@version, @@version_comment" # Show version
- sleep 5 # Give the mysql_upgrade a bit of time to complete before querying the server
- mysql --skip-column-names -e "SELECT @@version, @@version_comment"
- mysql -e "SELECT Host,User,plugin,authentication_string FROM user;" mysql
- mysql -e "SELECT * FROM plugin;" mysql
- echo 'SHOW DATABASES;' | mariadb # List databases before upgrade are still there
- mariadb -e "create database test; use test; create table t(a int primary key) engine=innodb; insert into t values (1); select * from t; drop table t; drop database test;" # Test InnoDB works
variables:
......
......@@ -111,11 +111,13 @@ EOF
$ERR_LOGGER
set -e
# Create the credentials file if not present. On all new installs the
# root account can be used directly for maintenance authenticated by
# unix socket and on new installs there is no need to define a
# separate Debian maintenance user account.
# On new installations root user can connect via unix_socket.
# But on upgrades, scripts rely on debian-sys-maint user and
# credentials in /etc/mysql/debian.cnf
# All tools use --defaults-file=/etc/mysql/debian.cnf
# And while it's not needed for new installations, we keep using
# --defaults-file option for tools (for the sake of upgrades)
# and thus need /etc/mysql/debian.cnf to exist, even if it's empty.
dc=$mysql_cfgdir/debian.cnf;
if [ ! -d "$mysql_cfgdir" ]; then
install -o 0 -g 0 -m 0755 -d $mysql_cfgdir
......@@ -137,21 +139,10 @@ EOF
echo "socket = $mysql_rundir/mysqld.sock" >>$dc
echo "basedir = /usr" >>$dc
fi
# If this dir chmod go+w then the admin did it. But this file should not.
# Keep it only root-readable, as it always was
chown 0:0 $dc
chmod 0600 $dc
# Update password column format
# Rename auth_socket potentially left over from a MySQL installation
password_column_fix_query=`/bin/echo -e \
"USE mysql;\n" \
"SET sql_log_bin=0;\n" \
"UPDATE user SET plugin='unix_socket' WHERE plugin='auth_socket';\n" \
"ALTER TABLE user CHANGE Password Password char(41) character set latin1 collate latin1_bin DEFAULT '' NOT NULL;"`
# NOTE: $MYSQL_BOOTSTRAP requires one SQL statement per line, semicolon at the end.
echo "$password_column_fix_query" | $MYSQL_BOOTSTRAP 2>&1 | $ERR_LOGGER
;;
abort-upgrade|abort-remove|abort-configure)
......
Description: Automate upgrades from MySQL with auth_socket to MariaDB with our unix_socket
Forwarded: https://jira.mariadb.org/browse/MDEV-18768
Author: Otto Kekäläinen <otto@mariadb.org>
Last-Update: 2019-04-18
--- a/scripts/mysql_system_tables_fix.sql
+++ b/scripts/mysql_system_tables_fix.sql
@@ -179,6 +179,13 @@ ALTER TABLE user
ALTER TABLE user
ADD Password char(41) character set latin1 collate latin1_bin NOT NULL default '' AFTER User;
+# In MySQL the Unix socket authentication plugin has a different name than in MariaDB
+# and thus the references to if needs to be renamed in the user table.
+UPDATE user
+ SET plugin='unix_socket' WHERE plugin='auth_socket';
+UPDATE plugin
+ SET name='unix_socket', dl='unix_socket.so' WHERE name='auth_socket';
+
ALTER TABLE user
MODIFY Password char(41) character set latin1 collate latin1_bin NOT NULL default '',
MODIFY Select_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL,
......@@ -15,3 +15,4 @@ mips-compilation-failure-__bss_start-symbol-miss.patch
rocksdb-js-source.patch
hurd-symbols.patch
tokudb-libjemalloc.patch
MDEV-18768-automate-auth_socket-to_unix_socket-upgrade.patch
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment