7

I'm developing locally and using Mamp Pro. Basically MySQL is having trouble starting and here's the error message from the error log:

Any idea how to resolve this?

2017-03-02 00:39:08 9518 [Note] Plugin 'FEDERATED' is disabled.
2017-03-02 00:39:08 9518 [Note] InnoDB: Using atomics to ref count buffer pool pages
2017-03-02 00:39:08 9518 [Note] InnoDB: The InnoDB memory heap is disabled
2017-03-02 00:39:08 9518 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2017-03-02 00:39:08 9518 [Note] InnoDB: Memory barrier is not used
2017-03-02 00:39:08 9518 [Note] InnoDB: Compressed tables use zlib 1.2.8
2017-03-02 00:39:08 9518 [Note] InnoDB: Using CPU crc32 instructions
2017-03-02 00:39:08 9518 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2017-03-02 00:39:08 9518 [Note] InnoDB: Completed initialization of buffer pool
2017-03-02 00:39:08 9518 [Note] InnoDB: Highest supported file format is Barracuda.
2017-03-02 00:39:08 9518 [Note] InnoDB: Log scan progressed past the checkpoint lsn 663573438
2017-03-02 00:39:08 9518 [Note] InnoDB: Database was not shutdown normally!
2017-03-02 00:39:08 9518 [Note] InnoDB: Starting crash recovery.
2017-03-02 00:39:08 9518 [Note] InnoDB: Reading tablespace information from the .ibd files...
2017-03-02 00:39:08 9518 [ERROR] InnoDB: Attempted to open a previously opened tablespace. Previous tablespace affiliate_blog_1_old/wpab1_7_woocommerce_order_itemmeta uses space ID: 367 at filepath: ./affiliate_blog_1_old/wpab1_7_woocommerce_order_itemmeta.ibd. Cannot open tablespace freshwp/freshwp_wfblocksadv which uses space ID: 367 at filepath: ./freshwp/freshwp_wfblocksadv.ibd
2017-03-02 00:39:08 7fff7b652000  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 ./freshwp/freshwp_wfblocksadv.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.
170302 00:39:08 mysqld_safe mysqld from pid file /Applications/MAMP/tmp/mysql/mysql.pid ended

From the above code the error seems to be:

2017-03-02 00:39:08 9518 [ERROR] InnoDB: Attempted to open a previously opened tablespace.

Previous tablespace affiliate_blog_1_old/wpab1_7_woocommerce_order_itemmeta uses space ID: 367 at filepath: ./affiliate_blog_1_old/wpab1_7_woocommerce_order_itemmeta.ibd.

Cannot open tablespace freshwp/freshwp_wfblocksadv which uses space ID: 367 at filepath: ./freshwp/freshwp_wfblocksadv.ibd

Treb
  • 87
  • 1
  • 1
  • 5
  • 2
    This is a really nice error message. It not only tells you what happened and why, it also gives you 3 options on how to fix the problem. Did you try them? (Also: Just in case, make a copy of your data directory first). – Solarflare Mar 02 '17 at 12:20
  • What happened before this? There appears to have been either a crash and/or some ill-advised tinkering with the data files. – Michael - sqlbot Mar 03 '17 at 02:21
  • @Solarflare yes I tried option 3 by adding "innodb_force_recovery > 0" but it didn't do anything. The other solutions... well I'm just not comfortable executing them / don't know how. – Treb Mar 04 '17 at 04:11
  • @Michael-sqlbot I was working on my WP site on the admin backend pages and just setting up the site and I don't know, nothing unusual. – Treb Mar 04 '17 at 04:12
  • How did you add "innodb_force_recovery > 0"? It means: add e.g. `innodb_force_recovery=1` to your config file under `[mysqld]`. And now the disclaimer: your database is currently corrupt after a crash (probably of your whole system). Any attempts to repair it might brake it more. A force recovery will in most cases loose the data in that table, and maybe more, so you have to replace it from a backup (just like option 2) or start all over. We cannot guarantee that you will not brake the database more, nor that there is no way you could have recovered your data. Also you will not know if that – Solarflare Mar 04 '17 at 11:53
  • 1
    is the only error, and/or if the database will work afterwards (or maby ejust seem to work). Or if there isn't some underlying reason for the crash (e.g. broken ram or hdd). To improve your odds, you could hire someone to do that for you. But in your case it seems not to be a production site nor important data, and reinstalling your wp theme might repair it. So be happy it happened now and not later. Use this as a hint to do backups (there are wordpress plugins for that). This would be by the way the first thing anyone you hire will ask: "How old is your backup". – Solarflare Mar 04 '17 at 11:53
  • This is related to this question and has the correct answer: http://stackoverflow.com/questions/41602359/mamp-pro-mysql-cant-start – Andrew Lazarus Apr 19 '17 at 08:13

1 Answers1

20

Recently encountered similar issue developing locally w/ MAMP. Log included "Database was not shutdown normally", similar error messages after that point, and the suggestions as well. Below are steps that resolved it:

  1. Stop servers in MAMP
  2. Navigate to the .idb files for your WP DB - if using MAMP, should be somewhere like ~/Library/Application Support/appsolute/MAMP PRO/db/mysql56/[yourdbname]/
  3. Add .bk (or any unrecognizable extension) to the end of the .idb filenames
  4. Start servers in MAMP. If you view logs, you'll see a bunch of error messages related to not finding the .idb files, but at least MySQL should start.
  5. Stop servers in MAMP
  6. Drop the .bk (or whatever you used) from the .idb file names
  7. Start servers in MAMP - at this point, should be all set.

Hadn't yet done much work with the DB, so was willing to lose data or even reinstall MAMP; if your situation is different, probably best to first backup your db directory to a .zip file so you can try something else later if no luck.

Hope this helps.

....

UPDATE:
Have found it faster to replace steps 3 and 6 with the following:
3. Create a temporary folder somewhere handy; select all the .idb files and move them into that folder.
6. Move the files back into the original folder from Step 2. ....

John
  • 544
  • 3
  • 7