Skip navigation links

User Comments

Posted by Kristian Koehntopp on March 27 2008 2:29pm[Delete] [Edit]

Be careful when you have multiple instances of mysqld running on the same box.

mysql_upgrade reads the sections [mysql_upgrade] and [client] for default values. The values required for an update, notably datadir and friends, are in [mysqld], though. Thus, it will touch the default datadir in /var/lib/mysql as it will not see your special datadir.

You cannot copy my.cnf and rename [mysqld] to [mysql_upgrade], because mysql_upgrade chokes on all the mysqld options. Instead filter the options you need like this:

( echo '[mysql_upgrade]';
--defaults-file=$PATHTO/my.cnf mysqld |
egrep '(datadir|basedir|user|password|socket)' |
sed -e 's/^--//';
) >> $PATHTO/my.cnf

Now mysqld_upgrade will find the information necessary to run properly. Check with

mysql_upgrade --defaults-file=$PATHTO/my.cnf --print-defaults

then run with

mysql_upgrade --defaults-file=$PATHTO/my.cnf -v

Posted by Michelle Steel on November 4 2008 2:25pm[Delete] [Edit]

If you are running multiple instances of MySQL, then you need to use the port number or socket name in the options list otherwise mysqlcheck will just check the default data directory.

E.g. if you have three instances of MySQL on port 3306, 3307 and 3308, you would need to run mysql_upgrade three times:

shell>mysql_upgrade -P3306 [options]
shell>mysql_upgrade -P3307 [options]
shell>mysql_upgrade -P3308 [options]

Posted by Frank Jonas on May 27 2010 6:19am[Delete] [Edit]

In Addition to the post above I want to add the a explanation which I got from the MySQL-support:

Sure, you can run something similar to the follows:
shell> mysql_upgrade -h --port=3308

Please note that is very important to specify -h if you use the port number, or mysql_upgrade will try to connect using the UNIX socket, de facto ignoring the port number.

Or else:
shell> mysql_upgrade -S /path/to/socket

Posted by Juri Sinitson on June 10 2013 9:53am[Delete] [Edit]

You may become login-errors when executing mysql_upgrade. In this case supply the login-data to mysql_upgrade like this:

shell> mysql_upgrade -u root -p

You may also need to stop the mysql daemon before executing mysql_upgrade and start it again when mysql_upgrade has completed.