您好,欢迎访问一九零五行业门户网

MySQL从MyISAM转换成InnoDB错误与常用解决办法_MySQL

bitscn.com
原来自己用的是为了装的, 所以在设置database usage(如下图1)的时候按照discuz官方的建议,选的都是non-transactional database only(只支持myisam数据引擎的非事务数据库),用myisam数据库,还没涉及到需要innodb,因此打算直接不加载innodb引擎。后来在做wordpress,一开始还不知道原来wordpress用的是innodb数据引擎,于是在原来的数据库里面就建了一个数据库,一开始也没发觉问题,安装,导入sql,都没问题,当时也没多想。直到这几天因为又要装多一个wordpress,用phpmyadmin访问数据库多一点,问题来了。老是一访问wordpress的数据库,就弹出错误提示“mysqld-nt.exe应用程序错误:“0x005346c4”指令引用的“0x00786000”内存,该内存不能为读...”,然后就mysql服务也停了,登陆不了,整个数据库都访问不了。
图1 设置数据库类型
纠结了挺久,也忘了是看到什么文章触发了灵感,反正后来才知道原来是数据引擎不同惹的祸。于是就想到重新运行次设置向导,把数据库类型改成支持innodb引擎的。马上行动,在向导里设置数据库类型(也就是图1的database usage)那里,设置成第二项,还在后面的innodb tablespace settings里把innodb数据文件设置放在d:/mysql innodb datafiles目录里。但是在最后execute执行的时候,却老是在start service那里出问题,如下图2。
图2 start service出错
想直接到services.msc里面启动服务,也不行。错误提示内容为:“在 本地计算机 无法启动mysql服务 错误1067:进程意外中止。”按照网上的某些做法,卸载了mysql服务,也没重启就重新设置,问题如故;把服务卸载了,重启后再重新设置,则是启动服务成功,但是在后面的applying security settings的时候有新的问题,如下图3。图2那里的错误提示则变成“error 2003: can't connect to mysql server on 'localhost' (10061), 说明mysql还是没有启动,或者启动过,出错又关了。
顺便提一下,在mysql5里(其他版本的我不知道)每运行一次设置向导,只要按了execute执行,都会在mysql5的安装目录下自动生成一个原来的mysql的设置文件my.ini的备份bak文件。并且将以修改的时间命名。因此如果设置出了问题,可以从备份文件恢复。
后来还是在错误日志里找到思路。错误日志就是放在 mysql5安装目录/data 目录里的那个以你的计算机名命名的.err文件。首先我找到以下一段:innodb: error: log file ./ib_logfile0 is of different size 0 52428800 bytesinnodb: than specified in the .cnf file 0 10485760 bytes!101001  9:47:42 [error] default storage engine (innodb) is not available101001  9:47:42 [error] aborting
101001  9:47:42 [note] d:/mysql5/bin/mysqld-nt: shutdown complete
于是就到“mysql5安装目录/data ”目录里把ib_logfile0日志文件删掉,重启mysql服务,还是提示10067错误。再去查看err文件。101001 18:39:29  innodb: log file ./ib_logfile0 did not exist: new to be createdinnodb: setting log file ./ib_logfile0 size to 109 mbinnodb: database physically writes the file full: wait...innodb: progress in mb: 100innodb: error: log file ./ib_logfile1 is of different size 0 52428800 bytesinnodb: than specified in the .cnf file 0 114294784 bytes!101001 18:39:30 [error] default storage engine (innodb) is not available101001 18:39:30 [error] aborting
101001 18:39:30 [note] d:/mysql5/bin/mysqld-nt: shutdown complete
可以看到,ib_logfile0的问题解决了,但是同样的问题却出在ib_logfile1上面了。于是依样画葫芦,把ib_logfile1删了,再重启mysql服务,却发现没用。难道是还要重启系统。果真,把前面两个ib_logfile删了,重启系统就搞定了。前面的可能是因为刚开机,所以也行。实际上是需要重启系统的。这时的日志如下101001 19:19:24  innodb: log file ./ib_logfile0 did not exist: new to be createdinnodb: setting log file ./ib_logfile0 size to 109 mbinnodb: database physically writes the file full: wait...innodb: progress in mb: 100101001 19:19:26  innodb: log file ./ib_logfile1 did not exist: new to be createdinnodb: setting log file ./ib_logfile1 size to 109 mbinnodb: database physically writes the file full: wait...innodb: progress in mb: 100innodb: cannot initialize created log files becauseinnodb: data files are corrupt, or new data files wereinnodb: created when the database was started previousinnodb: time but the database was not shut downinnodb: normally after that.101001 19:19:27 [error] default storage engine (innodb) is not available101001 19:19:27 [error] aborting
101001 19:19:27 [note] d:/mysql5/bin/mysqld-nt: shutdown complete
好了,现在只剩下最后一个问题了default storage engine (innodb) is not available。去services.msc里面启动mysql服务,还是出错。但是日志却是显示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 managedinnodb: to create the innodb data files, but log file creation failed.innodb: if that is the case, please refer toinnodb: http://dev.mysql.com/doc/mysql/en/error_creating_innodb.html101001 20:45:09 [error] default storage engine (innodb) is not available101001 20:45:09 [error] aborting
101001 20:45:09 [note] d:/mysql5/bin/mysqld-nt: shutdown complete
于是去网上搜索了一下,发现提示no valid checkpoint found.的解决办法:删除所有现有的ibdatan和ib_logfilen文件后,重启mysql。于是照做,果然行了。innodb: the first specified data file d:/mysql innodb datafiles/ibdata1 did not exist:innodb: a new database to be created!101001 21:04:24  innodb: setting file d:/mysql innodb datafiles/ibdata1 size to 10 mbinnodb: database physically writes the file full: wait...101001 21:04:25  innodb: log file ./ib_logfile0 did not exist: new to be createdinnodb: setting log file ./ib_logfile0 size to 109 mbinnodb: database physically writes the file full: wait...innodb: progress in mb: 100101001 21:04:27  innodb: log file ./ib_logfile1 did not exist: new to be createdinnodb: setting log file ./ib_logfile1 size to 109 mbinnodb: database physically writes the file full: wait...innodb: progress in mb: 100innodb: doublewrite buffer not found: creating newinnodb: doublewrite buffer createdinnodb: creating foreign key constraint system tablesinnodb: foreign key constraint system tables created101001 21:04:31  innodb: started; log sequence number 0 0101001 21:04:32 [note] d:/mysql5/bin/mysqld-nt: ready for connections.version: '5.0.18-nt'  socket: ''  port: 3306  mysql community edition (gpl)
奋斗了一天,总算成功地把mysql从myisam转换成innodb引擎了。也学会了读懂错误日志文件err文件了。不过我就在想了,如果从一开始就按照上面的做,不知道会怎么样呢?bitscn.com
其它类似信息

推荐信息