Home  >  Article  >  Database  >  MySQL不支持InnoDB的解决方法

MySQL不支持InnoDB的解决方法

WBOY
WBOYOriginal
2016-06-07 18:02:011151browse

在OpenSUSE下装上MySQL后,发现无法选择添加事务支持数据引擎InnoDB。

G一下后,解决如下:
/var/lib/mysql目录下,删除ibdata1、ib_logfile1、 ib_logfile0,然后重启MySql让其重建以上文件:
mysqladmin -uroot -p shutdown
sudo mysqld_safe &
搞定!

下面是网络上的其它文章。大家也可以参考下。
早上起来,到PHP站点去看了下,准备测试下别人写的一个CMS系统,高兴的下载了程序,然后把程序拷贝到所在目录。由于该程序没有install.php,里面只包含了一个*.sql的数据库语句,只得到mysql数据库中去执行这条语句:
进入数据库后,输入source 所在目录/*.sql
这个时候问题出现了:
QUOTE:
代码如下:
MySQL Server Error:
The 'InnoDB' feature is disabled; you need MySQL built with 'InnoDB' to have it working

在mysql中输入SHOW variables like "have_%"查看,显示如下:
代码如下:
mysql> SHOW variables like "have_%"
-> ;
+-----------------------+----------+
| Variable_name | Value |
+-----------------------+----------+
| have_archive | YES |
| have_bdb | NO |
| have_blackhole_engine | NO |
| have_compress | YES |
| have_crypt | NO |
| have_csv | NO |
| have_dynamic_loading | YES |
| have_example_engine | NO |
| have_federated_engine | NO |
| have_geometry | YES |
| have_innodb | DISABLED |
| have_isam | NO |
| have_merge_engine | YES |
| have_ndbcluster | NO |
| have_openssl | DISABLED |
| have_query_cache | YES |
| have_raid | NO |
| have_rtree_keys | YES |
| have_symlink | YES |
+-----------------------+----------+
19 rows in set (0.00 sec)

蓝色表示我的MYSQL并不支持innodb。


MySQL中InnoDB和MyISAM类型的差别
代码如下:
InnoDB和MyISAM是在使用MySQL最常用的两个表类型,各有优缺点,视具体应用而定。下面是已知的两者之间的差别,仅供参考。
1.InnoDB不支持FULLTEXT类型的索引。
2.InnoDB 中不保存表的具体行数,也就是说,执行select count(*) from table时,InnoDB要扫描一遍整个表来计算有多少行,但是MyISAM只要简单的读出保存好的行数即可。注意的是,当count(*)语句包含 where条件时,两种表的操作是一样的。
3.对于AUTO_INCREMENT类型的字段,InnoDB中必须包含只有该字段的索引,但是在MyISAM表中,可以和其他字段一起建立联合索引。
4.DELETE FROM table时,InnoDB不会重新建立表,而是一行一行的删除。
5.LOAD TABLE FROM MASTER操作对InnoDB是不起作用的,解决方法是首先把InnoDB表改成MyISAM表,导入数据后再改成InnoDB表,但是对于使用的额外的InnoDB特性(例如外键)的表不适用。
另外,InnoDB表的行锁也不是绝对的,如果在执行一个SQL语句时MySQL不能确定要扫描的范围,InnoDB表同样会锁全表,例如update table set num=1 where name like “%aaa%”
任何一种表都不是万能的,只用恰当的针对业务类型来选择合适的表类型,才能最大的发挥MySQL的性能优势。
如果你想使用外键,事务等功能,记得用innodb引擎。使用方法是create table xxx()engine=innodb;如果想所有建立的表格都用innodb引擎,可以把“default-storage-engine=INNODB”加到/etc/mysql/my.cnf(位置可能不同)。设完之后就可以用“show engines;”检查是否设置好。不过据说该设置在5.0.22下可能无效。

网上查找了,打开我的my.ini文件,找到skip-innodb,改成#skip-innodb。

之后重启mysql。。问题解决。
代码如下:
mysql> SHOW variables like "have_%"
-> ;
+-----------------------+----------+
| Variable_name | Value |
+-----------------------+----------+
| have_archive | YES |
| have_bdb | NO |
| have_blackhole_engine | NO |
| have_compress | YES |
| have_crypt | NO |
| have_csv | NO |
| have_dynamic_loading | YES |
| have_example_engine | NO |
| have_federated_engine | NO |
| have_geometry | YES |
| have_innodb | YES |
| have_isam | NO |
| have_merge_engine | YES |
| have_ndbcluster | NO |
| have_openssl | DISABLED |
| have_query_cache | YES |
| have_raid | NO |
| have_rtree_keys | YES |
| have_symlink | YES |
+-----------------------+----------+
19 rows in set (0.00 sec)
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn