Upgrading MySQL 5.1 to 5.7 service failed to start

mysql-logo-imageAfter MySQL upgrade from 5.1 to 5.7 on Centos 6.8 the mysqld service failed to start. In /var/log/mysqld.log I got the following:

2017-01-14 17:19:33 2175 [ERROR] InnoDB: auto-extending data file ./ibdata1 is of a different size 640 pages (rounded down to MB) than specified in the .cnf file: initial 768 pages, max 0 (relevant if non-zero) pages!
2017-01-14 17:19:33 2175 [ERROR] InnoDB: Could not open or create the system tablespace. If you tried to add new data files to the system tablespace, and it failed here, you should now edit innodb_data_file_path in my.cnf back to what it was, and remove the new ibdata files InnoDB created in this failed attempt. InnoDB only wrote those files full of zeros, but did not yet use them in any way. But be careful: do not remove old data files which contain your precious data!
2017-01-14 17:19:33 2175 [ERROR] Plugin ‘InnoDB’ init function returned error.
2017-01-14 17:19:33 2175 [ERROR] Plugin ‘InnoDB’ registration as a STORAGE ENGINE failed.
2017-01-14 17:19:33 2175 [ERROR] Unknown/unsupported storage engine: InnoDB
2017-01-14 17:19:33 2175 [ERROR] Aborting

To solve this problem add the below given line in /etc/my.cnf file inside [mysqld] block.

Now restart the mysqld service.
service mysqld restart

In case it fails check the MySQL log file again: you probably need tables upgrade.
2017-01-14 17:19:33 0 [ERROR] Fatal error: mysql.user table is damaged. Please run mysql_upgrade.
2017-01-14 17:19:33 0 [ERROR] Aborting

The confusing thing here is that you can’t run mysql_upgrade immediately as you need mysqld running. But you can’t run mysqld because you need to upgrade the tables first! Sad and funny at the same time! 🙂

The answer here is to run mysql without reading user tables:

mysqld --skip-grant-tables

You will get mysql running in foreground. Now open second terminal session and run

mysql_upgrade

Ensure all tables are updated now and kill mysqld process:

killall mysqld

Now run mysqld as usual:

Done!

Be sociable 🙂 Share!
error

Comments/Коментарі/Комментарии