lampp+wordpress主机数据库错误修复方法

突然断电后可能会导致wordpress+mysql数据链接不上的问题。
重启lampp显示mysql ok
手动启动/lampp/sbin/mysqld显示一堆错误
查阅/lampp/var/mysql/*.err文件,查找错误描述:
2016-04-05 08:16:21 1303 mysqld_safe Starting mysqld daemon with databases from /opt/lampp/var/mysql
2016-04-05 8:16:21 3072055040 [Note] /opt/lampp/sbin/mysqld (mysqld 10.1.8-MariaDB) starting as process 1446 …
2016-04-05 8:16:21 3072055040 [Note] InnoDB: Using mutexes to ref count buffer pool pages
2016-04-05 8:16:21 3072055040 [Note] InnoDB: The InnoDB memory heap is disabled
2016-04-05 8:16:21 3072055040 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2016-04-05 8:16:21 3072055040 [Note] InnoDB: Memory barrier is not used
2016-04-05 8:16:21 3072055040 [Note] InnoDB: Compressed tables use zlib 1.2.8
2016-04-05 8:16:21 3072055040 [Note] InnoDB: Not using CPU crc32 instructions
2016-04-05 8:16:21 3072055040 [Note] InnoDB: Initializing buffer pool, size = 16.0M
2016-04-05 8:16:21 3072055040 [Note] InnoDB: Completed initialization of buffer pool
2016-04-05 8:16:21 3072055040 [Note] InnoDB: Highest supported file format is Barracuda.
2016-04-05 8:16:21 3072055040 [Note] InnoDB: The log sequence numbers 24828281 and 24828281 in ibdata files do not match the log sequence number 28745284 in the ib_logfiles!
2016-04-05 8:16:21 3072055040 [Note] InnoDB: Database was not shutdown normally!
2016-04-05 8:16:21 3072055040 [Note] InnoDB: Starting crash recovery.
2016-04-05 8:16:21 3072055040 [Note] InnoDB: Reading tablespace information from the .ibd files…
2016-04-05 8:16:23 3072055040 [ERROR] InnoDB: Attempted to open a previously opened tablespace. Previous tablespace wordpress/wp_options uses space ID: 14 at filepath: ./wordpress/wp_options.ibd. Cannot open tablespace phpmyadmin/pma__bookmark which uses space ID: 14 at filepath: ./phpmyadmin/pma__bookmark.ibd
2016-04-05 08:16:23 b71bd700 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 ./phpmyadmin/pma__bookmark.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.
2016-04-05 08:16:23 1303 mysqld_safe mysqld from pid file /opt/lampp/var/mysql/ht-Lenovo.pid ended
解决办法:
1,删除/lampp/var/mysql/ib_logfile0和ib_logfile1,保险起见,建议mv换个名字。
2,修订mysql配置文件/lampp/etc/my.cnf,在[mysqld]下增加innodb_force_recovery = 2,保存
3,手动启动mysql服务/lampp/sbin/mysqld
4,回到my.cnf文件,注释掉增加的内容。
5,重启lampp, sudo ./lampp restart
6,OK 结束。