MySQL InnoDB problems - InnoDB registration fails - mysql

I recently attempted to upgrade a MySQL 5.1 server to 5.7. When the server wouldn't start, I discovered you have to export the data first, else do numerous upgrades (the binaries for which aren't available anymore), so I rolled back to 5.1 to do an export.
The problem is, back on 5.1, InnoDB will no longer register. In the error log i get:
InnoDB: Error: log file ./ib_logfile0 is of different size 0 50331648 bytes
InnoDB: than specified in the .cnf file 0 5242880 bytes!
160822 17:05:12 [ERROR] Plugin 'InnoDB' init function returned error.
160822 17:05:12 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
As a workaround I set innodb_log_file_size=50331648 in my.cnf. Another restart and:
InnoDB: No valid checkpoint found.
InnoDB: If this error appears when you are creating an InnoDB database,
InnoDB: the problem may be that during an earlier attempt you managed
InnoDB: to create the InnoDB data files, but log file creation failed.
InnoDB: If that is the case, please refer to
InnoDB: http://dev.mysql.com/doc/refman/5.1/en/error-creating-innodb.html
Reading that links it suggests to delete all files created by InnoDB: all ibdata files and all ib_logfile files. I have a 120 GB ibdata file that I most certainly do not intend to delete, so this is a non-starter. I did try renaming the logfiles though and the server still wouldn't come up.
Any pointers from here?
Edit: I also tried renaming the iblog files. That causes another error where mysql suggests setting innodb_force_recovery=6. Doing that causes these errors:
160823 12:17:32 InnoDB: Page checksum 271832187, prior-to-4.0.14-form checksum 315921779
InnoDB: stored checksum 401867329, prior-to-4.0.14-form stored checksum 401867329
InnoDB: Page lsn 96 3891045697, low 4 bytes of lsn at page end 3891045697
InnoDB: Page number (if stored to page already) 966706,
InnoDB: space id (if created with >= MySQL-4.1.1 and stored already) 0
InnoDB: Page may be a system page
InnoDB: Database page corruption on disk or a failed
InnoDB: file read of page 966706.
InnoDB: You may have to recover from a backup.
InnoDB: It is also possible that your operating
InnoDB: system has corrupted its own file cache
InnoDB: and rebooting your computer removes the
InnoDB: error.
InnoDB: If the corrupt page is an index page
InnoDB: you can also try to fix the corruption
InnoDB: by dumping, dropping, and reimporting
InnoDB: the corrupt table. You can use CHECK
InnoDB: TABLE to scan your table for corruption.
InnoDB: See also http://dev.mysql.com/doc/refman/5.1/en/forcing-innodb-recovery.html
InnoDB: about forcing recovery.
InnoDB: Database page corruption on disk or a failed
InnoDB: file read of page 966707.
InnoDB: You may have to recover from a backup.
160823 12:17:32 InnoDB: Page dump in ascii and hex (16384 bytes):

I encounter the similar problem just now. I run both MySQL 5.1 and 5.7 in the same server.
With MySQL 5.1, the default innodb_log_file_size is 5m.
mysql> show variables like 'innodb_log_file_size';
+----------------------+---------+
| Variable_name | Value |
+----------------------+---------+
| innodb_log_file_size | 5242880 |
+----------------------+---------+
1 row in set (0.00 sec)
While MySQL 5.7, the default innodb_log_file_size is 48m.
mysql> show variables like 'innodb_log_file_size';
+----------------------+----------+
| Variable_name | Value |
+----------------------+----------+
| innodb_log_file_size | 50331648 |
+----------------------+----------+
1 row in set (0.01 sec)
When upgrade a MySQL 5.1 server to 5.7 and then downgrade to 5.1, the ib_logfile0/1 file was changed in a magic way. The checkpoint of log file cannot be identified. So innodb cannot execute a normal recovery using the log files. I didn't make a deep research so i can't give a detailed explanation.
Solution
Backup datafile and restart MySQL
mv ibdata1 ibdata1.bak
mv ib_logfile0 ib_logfile0.bak
mv ib_logfile1 ib_logfile1.bak
service mysqld restart
Modify my.cnf file, add the following line
innodb_force_recovery=6
Restore datafile and restart again
mv ibdata1.bak ibdata1
service mysqld restart
Now you will see MySQL start successfully. Ibdata1 may not work properly. You can backup your application data using mysqldump. Then remove the recovery line in my.cnf file. Remove ibdata and logfile as well. Restart MySQL and Import your backup.
A little complex, but these help me.
Faults
As the redo log file was recreated, a little piece of log cannot be redo.

Do not delete ibdata*. That is where all the data is!
By now, the log files should not matter. So, there are a couple of ways to deal with the 'error'.
Get back the old my.cnf. If that is not practical, at least set
innodb_log_file_size = 50331648
(The change to the log file is a bit tricky. Apparently 5.7 increased it to the new default of 48MB without a problem. However, 5.1 does not have the code to dynamically change the file size.)
Another approach is to delete (or move aside) the iblog* files.

Related

MySQL Not starting with MAMP

I know this might seem a duplicate, but I am struggling.
I managed to start and run Apache and MySQL for one session using MAMP. Come to it again, MySQL will not start.
I have tried various answers on Stack. Reinstalling / moving directories / making sure things are update. The one thing I haven't done, is renaming the 'ib_logfile' - because they are not there!
Anyone have any suggestions?
2017-09-23 20:44:46 7fffa5a753c0 InnoDB: Operating system error number 2 in a file operation.
InnoDB: The error means the system cannot find the path specified.
InnoDB: If you are installing InnoDB, remember that you must create
InnoDB: directories yourself, InnoDB does not create them.
InnoDB: Error: could not open single-table tablespace file ./mysql/slave_worker_info.ibd
InnoDB: We do not continue the crash recovery, because the table may become
InnoDB: corrupt if we cannot apply the log records in the InnoDB log to it.
InnoDB: To fix the problem and start mysqld:
InnoDB: 1) If there is a permission problem in the file and mysqld cannot
InnoDB: open the file, you should modify the permissions.
InnoDB: 2) If the table is not needed, or you can restore it from a backup,
InnoDB: then you can remove the .ibd file, and InnoDB will do a normal
InnoDB: crash recovery and ignore that table.
InnoDB: 3) If the file system or the disk is broken, and you cannot remove
InnoDB: the .ibd file, you can set innodb_force_recovery > 0 in my.cnf
InnoDB: and force InnoDB to continue crash recovery here.
170923 20:44:46 mysqld_safe mysqld from pid file /Applications/MAMP/tmp/mysql/mysql.pid ended
So far I got it working - I change the permissions for the Mysql folder in Mamp to read and write and all the containing folders and it seems to work.
go to /Applications/MAMP/tmp/mysql/ and add new file mysql.pid
restart mamp

MySQL fails to start after updating XAMPP

I recently updated my XAMPP version to be able to use PHP 7.
I had no problems migrating, so I copied the whole directory to my notebook to work on it.
There the MySQL service always crashed on startup. Having returned to my PC today I had to realize that MySQL won't start on my PC anymore.
2017-05-14 19:02:58 8200 [Note] InnoDB: The log sequence numbers 2453615 and 2453615 in ibdata files do not match the log sequence number 2453645 in the ib_logfiles!
2017-05-14 19:02:58 8200 [Note] InnoDB: Database was not shutdown normally!
2017-05-14 19:02:58 8200 [Note] InnoDB: Starting crash recovery.
2017-05-14 19:02:58 8200 [Note] InnoDB: Reading tablespace information from the .ibd files...
2017-05-14 19:02:58 8200 [ERROR] InnoDB: Attempted to open a previously opened tablespace. Previous tablespace bnw/bnwv1_games uses space ID: 29 at filepath: .\bnw\bnwv1_games.ibd. Cannot open tablespace phpmyadmin/pma__export_templates which uses space ID: 29 at filepath: .\phpmyadmin\pma__export_templates.ibd
This should be the interesting part from the error log. A message later it suggests to set innodb_force_recovery > 0, but then it only complains about missing db.MYI (and also MYD and also for server, user, event after creating empty files).
Since the ib_logfiles log sequence number increases by 10 on every attempted start and I'm quite sure there is no corrupted data in the DB, I think it would be enough to manually reset it. How can I do this?
Edit: Complete error log (from another start): https://pastebin.com/T7GRgK4v
Probably this issue is with the below line in [mysqld] section which somehow commented-out/removed from my.ini file:
key_buffer = 16M
After commenting this out this line will be:
#key_buffer = 16M
Please first check your Windows Event Viewer for more clues to the errors in XAMPP Control Panel.
Two issues...
InnoDB had some trouble. You changed innodb_force_recovery? And you changed it back, I hope.
MyISAM is having some kind of trouble with a table? Then do CHECK TABLE on the table in question, then do REPAIR TABLE on that table. That should fix and/or rebuild the .MYI (which contains the indexes for one MyISAM table).

MAMP how do I rescue my MySQL database

Apologies I am quite new at this, so the easier the better! I need to rescue a wordpress database from a corrupted MAMP installation.
This is the error I am receiving in the MySQL Log when I try and open MAMP:
https://codeshare.io/GqPykx
Thanks for any assistance!!
K
You could start by applying the specified methods to restore to a known state. If you're lucky you have permissions problem you just need to fix on the table storage files, if you're unlucky you should restore from your backup disk.
InnoDB: The error means the system cannot find the path specified.
InnoDB: If you are installing InnoDB, remember that you must create
InnoDB: directories yourself, InnoDB does not create them.
InnoDB: Error: could not open single-table tablespace file ./olivia/wp_term_taxonomy.ibd
InnoDB: We do not continue the crash recovery, because the table may become
InnoDB: corrupt if we cannot apply the log records in the InnoDB log to it.
InnoDB: To fix the problem and start mysqld:
InnoDB: 1) If there is a permission problem in the file and mysqld cannot
InnoDB: open the file, you should modify the permissions.
InnoDB: 2) If the table is not needed, or you can restore it from a backup,
InnoDB: then you can remove the .ibd file, and InnoDB will do a normal
InnoDB: crash recovery and ignore that table.
InnoDB: 3) If the file system or the disk is broken, and you cannot remove
InnoDB: the .ibd file, you can set innodb_force_recovery > 0 in my.cnf
InnoDB: and force InnoDB to continue crash recovery here.

MySQL Server not starting with MAMP

My MySQL Server wont start anymore on MAMP. The solutions I found online said, that I should first quit MAMP, quit the MYSQL process, and start MAMP again.
But there is no MySQL process running in my situation, so this didn't work. Do you have any idea, what else could be the process?
You can find my error log here:
2017-01-20 21:40:03 7fff79bb0000 InnoDB: Operating system error
number 2 in a file operation. InnoDB: The error means the system
cannot find the path specified. InnoDB: If you are installing InnoDB,
remember that you must create InnoDB: directories yourself, InnoDB
does not create them. InnoDB: Error: could not open single-table
tablespace file ./yunityproject_wordpress/wp_comments.ibd InnoDB: We
do not continue the crash recovery, because the table may become
InnoDB: corrupt if we cannot apply the log records in the InnoDB log
to it. InnoDB: To fix the problem and start mysqld: InnoDB: 1) If
there is a permission problem in the file and mysqld cannot InnoDB:
open the file, you should modify the permissions. InnoDB: 2) If the
table is not needed, or you can restore it from a backup, InnoDB: then
you can remove the .ibd file, and InnoDB will do a normal InnoDB:
crash recovery and ignore that table. InnoDB: 3) If the file system or
the disk is broken, and you cannot remove InnoDB: the .ibd file, you
can set innodb_force_recovery > 0 in my.cnf InnoDB: and force InnoDB
to continue crash recovery here. 170120 21:40:04 mysqld_safe mysqld
from pid file /Applications/MAMP/tmp/mysql/mysql.pid ended
Just had this issue. Turns out a mysql.pid file was missing from the mamp\tmp\mysql\ folder. uninstalled, reinstalled and everything works. just make sure you delete the old mamp folder.
[coincidence? my mamp-pro license just expired and then this issue happened]

MySQL not starting, InnoDB not available

A client's server is running MySQL 5.0. Last night the server automatically restarted to install Windows updates. After restarting, MySQL does not want to run any more. The MySQL log indicates that it shut down normally. Windows logs shows the service can't start because "Default storage engine (InnoDB) is not available". MySQL was running fine for years before this and nothing was recently changed.
Daily backups are made of the data, and the installation directory is still there.
How do I get the MySQL service running again?
EDIT: I just noticed the following in the server.err file in the data folder:
InnoDB: Error: log file .\ib_logfile0 is of different size 0 10485760 bytes
InnoDB: than specified in the .cnf file 0 25165824 bytes!
120112 5:16:30 [ERROR] Default storage engine (InnoDB) is not available
120112 5:16:30 [ERROR] Aborting
You should stop mysql server, delete log file and start it again. It should work afterwards. Of course, make a backup first. If it doesn't work, try fix from this link.
You can edit the .cnf, search for innodb_log_file_size parameter and set the size (in Megabytes) that match the size of the ib_logfile0.
C:\MySql\data> dir
24/10/2012 08:47 24.117.248 ib_logfile0
Megas = 24117248 / 1024 / 1024 = 23
innodb_log_file_size=23M
That try to start the service.
Well done Aleksandar Vučetić!
I have deleted these files from "mysql/data":
- ib_logfile0
- ib_logfile1
- ibdata1
and MySQL Service is started again.
MySQL log says:
InnoDB: The first specified data file .\ibdata1 did not exist:
InnoDB: a new database to be created!
140719 0:57:55 InnoDB: Setting file .\ibdata1 size to 10 MB
InnoDB: Database physically writes the file full: wait...
140719 0:57:55 InnoDB: Log file .\ib_logfile0 did not exist: new to be created
InnoDB: Setting log file .\ib_logfile0 size to 54 MB
InnoDB: Database physically writes the file full: wait...
140719 0:57:56 InnoDB: Log file .\ib_logfile1 did not exist: new to be created
InnoDB: Setting log file .\ib_logfile1 size to 54 MB
InnoDB: Database physically writes the file full: wait...
InnoDB: Doublewrite buffer not found: creating new
InnoDB: Doublewrite buffer created
InnoDB: Creating foreign key constraint system tables
InnoDB: Foreign key constraint system tables created
140719 0:57:57 InnoDB: Started; log sequence number 0 0
In my case I had removed c:\windows\temp\myslql folder. I created "mysql" folder in temp again and viola it worked!
In my case, I could fix the issue by following commands. (On Ubuntu 20.04 (LTS) x64 DigitalOcean)
cd /var/lib/mysql
mkdir '#innodb_redo'
chown mysql:mysql '#innodb_redo'
systemctl restart mysql
I entered the server as root, but it should work as the same when you use sudo.