Using mysql_upgrade & fixing post upgrade issues for a successful upgrade

9:27 PM

As a general rule, to upgrade from one release series to another, you should go to the next series rather than skipping a series. To upgrade from a release series previous to MySQL 5.0, upgrade to each successive release series in turn until you have reached MySQL 5.0, and then proceed with the upgrade to MySQL 5.1. For example, if you currently are running MySQL 4.1 and wish to upgrade to a newer series, upgrade to MySQL 5.0 first before upgrading to 5.1, and so forth.
If you perform a binary (in-place) upgrade without dumping and reloading tables, you cannot upgrade directly from MySQL 4.1 to 5.1. This occurs due to an incompatible change in the MyISAM table index format in MySQL 5.0. Upgrade from MySQL 4.1 to 5.0 and repair all MyISAM tables. Then upgrade from MySQL 5.0 to 5.1 and check and repair your tables.
To upgrade from MySQL 5.0 to 5.1,
1) back up your databases, including the mysql database that contains the grant tables
2) Read pre-upgrade & release notes. These notes enable you to identify upgrade issues that apply to your current MySQL installation. Some incompatibilities discussed in that section require your attention before upgrading. Others should be dealt with after upgrading.
3)  After upgrading to a new version of MySQL, run mysql_upgrade. This program checks your tables, and attempts to repair them if necessary. It also updates your grant tables to make sure that they have the current structure so that you can take advantage of any new capabilities. (Some releases of MySQL introduce changes to the structure of the grant tables to add new privileges or features.). mysql_upgrade does not upgrade the contents of the help tables.  mysql_upgrade should be executed each time you upgrade MySQL. If mysql_upgrade finds that a table has a possible incompatibility, it performs a table check and, if problems are found, attempts a table repair.
To use mysql_upgrade, make sure that the server is running, and then invoke it like this:  shell> mysql_upgrade options After running mysql_upgrade, stop the server and restart it so that any changes made to the system tables take effect.
mysql_upgrade executes the following commands to check and repair tables and to upgrade the system tables: mysql_upgrade also saves the MySQL version number in a file named mysql_upgrade_info in the data directory. This is used to quickly check whether all tables have been checked for this release so that table-checking can be skipped. To ignore this file and perform the check regardless, use the --force option. mysqlcheck --all-databases --check-upgrade --auto-repair
mysql < fix_priv_tables
 for example:
ROOT-(0)> /usr/bin/mysql_upgrade -uroot -p --force
Enter password:
Looking for 'mysql' as: /usr/bin/mysql
Looking for 'mysqlcheck' as: /usr/bin/mysqlcheck
Running 'mysqlcheck with default connection arguments
Running 'mysqlcheck with default connection arguments
authentication.authdata
error    : Table upgrade required. Please do "REPAIR TABLE `authdata`" or dump/reload to fix it!
authentication.cryptkeys    OK
authentication.tokens
error    : Table upgrade required. Please do "REPAIR TABLE `tokens`" or dump/reload to fix it!
croakapp20.CROAK    OK
croakapp20.CROAKLOGS  OK
croakapp20.CROAKMESSAGESTATS  OK
...
...
Repairing tables
authentication.authdata
note     : The storage engine for the table doesn't support repair
authentication.tokens
note     : The storage engine for the table doesn't support repair
 ...
...
Running 'mysql_fix_privilege_tables'...
OK
To rebuild table by dumping and reloading it, use mysqldump to create a dump file and mysql to reload the file:
 shell> mysqldumpdb_namet1 > dump.sql
shell> mysqldb_name< dump.sql
To rebuild all the tables in a single database, specify the database name without any following table name: shell> mysqldump db_name > dump.sql
shell> mysql db_name < dump.sql To rebuild all tables in all databases, use the --all-databases option:
shell> mysqldump --all-databases > dump.sql
shell> mysql < dump.sql
To rebuild a table with ALTER TABLE, use a "null" alteration; that is, an ALTER TABLE statement that "changes" the table to use the storage engine that it already has. For example, if t1 is a MyISAM table, use this statement: mysql> ALTER TABLE t1 ENGINE = MyISAM;
If you must rebuild a table because a table checking operation indicates that the table is corrupt or needs an upgrade, you can use REPAIR TABLE if that statement supports the table's storage engine. For example, to repair a MyISAM table, use this statement: mysql> REPAIR TABLE t1;
For storage engines such as InnoDB that REPAIR TABLE does not support, use mysqldump to create a dump file and mysql to reload the file or alternatively use alter table and change engine=MyISAM but dump/load is efficient if you have to run on one to many databases. But for innodb even though repair table is not supported, it runs drop & rebuild indexes which also fixes upgrade errors.
mysqlcheck --repair provides command-line access to the REPAIR TABLE statement. This can be a more convenient means of repairing tables because you can use the --databases or --all-databases option to repair all tables in specific databases or all databases, respectively: shell> mysqlcheck --repair --databases db_name ...
shell> mysqlcheck --repair --all-databases

You Might Also Like

0 comments

Contact Form

Name

Email *

Message *

Translate

Wikipedia

Search results