Today at work my computer randomly froze/crashed. On reboot MAMP refuses to start mysql and I can\'t figure out why. There are definitely no other mysql processes running; I
One of the pages in your ibdata1
file failed a checksum test as it was being read from disk, which causes MySQL to crash itself by design. They wouldn't want you to accidentally read data that was known to be corrupt, nor risk modifying any other data in an instance that's liable to corrupt it.
You can read tips on recovering the remaining data here: Recovering Innodb table Corruption.
The innodb_force_recovery
might or might not be able to help. Any read of the corrupt page will cause the server to crash again. The errors suggest the corrupt page is in the change buffer, which is processed by a background thread immediately upon startup. innodb_force_recovery=4
or higher will prevent the change buffer from being read.
It would probably be simpler, provided you have a backup of the database, to delete the ibdata1
file the ib_log*
files, and other .ibd
files, and then restore the backup. You can also replay binary logs for point-in-time recovery.
PREFACE: This sounds bad, but please be sure to read everything in this answer before acting. You can’t break things worse by taking your time. Read each step & hopefully this will be clear enough for you to follow & get your MySQL database server in MAMP Pro up and running again.
So, it seems like your InnoDB databases crashed. Not the app itself. The key is here in the log:
140527 15:06:58 InnoDB: highest supported file format is Barracuda.
InnoDB: Log scan progressed past the checkpoint lsn 791075520
140527 15:06:58 InnoDB: Database was not shut down normally!
InnoDB: Starting crash recovery.
InnoDB: Reading tablespace information from the .ibd files...
InnoDB: Restoring possible half-written data pages from the doublewrite
InnoDB: buffer...
InnoDB: Doing recovery: scanned up to log sequence number 791076717
InnoDB: Database page corruption on disk or a failed
InnoDB: file read of page 8402.
InnoDB: You may have to recover from a backup.
And it looks like you are using MAMP PRO over here:
/Library/Application Support/appsolute/MAMP PRO/db/mysql
So the question is, do you have a backup of the MAMP Pro databases? Either via mysqldump
or something else? Do you have other InnoDB databases in your MAMP install?
Also, you say you were able to run mysqldump
, but it’s really not possible of the database crashed. So I am assuming when you ran mysqldump
that was another, separate install of MySQL on your system. The MySQL binaries such as mysqldump
in MAMP or MAMP Pro are not the same as the systemwide mysqldump
. They are two 100% different installs. You can check which mysqldump
is being used by typing in this command:
which mysqldump
To see the full path of what you believe you were using. The MAMP install of mysqldump
—and other related binaries—is located here:
/Applications/MAMP/Library/bin/
And to run it directly without modifying your $PATH
value (a whole other thing) is to run it like this:
/Applications/MAMP/Library/bin/mysqldump
PLEASE READ CAREFULLY: Please note the advice I am giving you below is me presenting every way I would deal with a situation like this. If the InnoDB database is not important, just do my first suggestion of trashing the InnoDB specific DB files. If you have a mysqldump
backup, do the same thing but recover the mysqldump
backup.
Also, InnoDB is not a default storage engine. You have to go out of your way to set that. The default is MyISAM. Any new DB created in MySQL will be MyISAM. So this will help you. You need to put on your thinking cap an figure out which databases have InnoDB storage engines set. If you say you have 25 but only 1 has InnoDB, easy solution. But also if you have 25 databases, you should get into the habit of making regular mysqldump
backups. If you had backups, this would be a headache but a straight forward thing to solve.
ONE OPTION: Delete the corrupted InnoDB stuff & recover from a mysqldump
backup.
The first thing I would do if I were you is backup the mysql
directory in /Library/Application Support/appsolute/MAMP PRO/db/
so you can at least have a backup of the corrupted files just in case.
Then I would delete the following files:
/Library/Application Support/appsolute/MAMP PRO/db/mysql/ib_logfile0
/Library/Application Support/appsolute/MAMP PRO/db/mysql/ib_logfile1
/Library/Application Support/appsolute/MAMP PRO/db/mysql/ibdata1
Those are InnoDB specific files. Delete them and then attempt to start MAMP again. It should come up. But any InnoDB database in MAMP will be in some “zombie” state. You should delete those databases & recreate from backup. Or from scratch if you can.
ANOTHER OPTION: Try to get the MySQL server up & running again with innodb_force_recovery
.
Now on the offhand chance you need to recover that DB, you can run attempt to set a innodb_force_recovery as described here.
For MAMP Pro it seems you can edit your MySQL configuration file as per these instructions:
innodb_force_recovery = 1
And as the MySQL documentation explains, this is strictly to get the database up and running so you can make a backup via mysqldump
:
In such cases, use the innodb_force_recovery option to force the InnoDB storage engine to start up while preventing background operations from running, so that you can dump your tables.
Now there are about 6 different values for innodb_force_recovery
but you should really only attempt with 1
for now. If you want to attempt each of the 6, here is a breakdown:
1 (SRV_FORCE_IGNORE_CORRUPT)
Lets the server run even if it detects a corrupt page. Tries to make SELECT * FROM tbl_name jump over corrupt index records and pages, which helps in dumping tables.
2 (SRV_FORCE_NO_BACKGROUND)
Prevents the master thread and any purge threads from running. If a crash would occur during the purge operation, this recovery value prevents it.
3 (SRV_FORCE_NO_TRX_UNDO)
Does not run transaction rollbacks after crash recovery.
4 (SRV_FORCE_NO_IBUF_MERGE)
Prevents insert buffer merge operations. If they would cause a crash, does not do them. Does not calculate table statistics.
5 (SRV_FORCE_NO_UNDO_LOG_SCAN)
Does not look at undo logs when starting the database: InnoDB treats even incomplete transactions as committed.
6 (SRV_FORCE_NO_LOG_REDO)
Does not do the redo log roll-forward in connection with recovery.
With this value, you might not be able to do queries other than a basic
SELECT * FROM t
, with noWHERE
,ORDER BY
, or other clauses. More complex queries could encounter corrupted data structures and fail.If corruption within the table data prevents you from dumping the entire table contents, a query with an
ORDER BY primary_key DESC
clause might be able to dump the portion of the table after the corrupted part.
If you happen to get the database up and running and then can do a mysqldump
then congratulations! You are in the clear! The best next steps is to
innodb_force_recovery
option from the MySQL config so the database server can operate normally.mysqldump
backup into the new database.And you should be done.