標籤:engine mysql error
[[email protected] mysql]# mysql -u root -p‘123456‘ jiang < schema.sql ERROR 1286 (42000) at line 1: Unknown table engine ‘InnoDB‘
mysql> select * from ENGINES;+------------+---------+-----------------------------------------------------------+--------------+------+------------+| ENGINE | SUPPORT | COMMENT | TRANSACTIONS | XA | SAVEPOINTS |+------------+---------+-----------------------------------------------------------+--------------+------+------------+| CSV | YES | CSV storage engine | NO | NO | NO || MRG_MYISAM | YES | Collection of identical MyISAM tables | NO | NO | NO || MEMORY | YES | Hash based, stored in memory, useful for temporary tables | NO | NO | NO || MyISAM | DEFAULT | Default engine as of MySQL 3.23 with great performance | NO | NO | NO |+------------+---------+-----------------------------------------------------------+--------------+------+------------+4 rows in set (0.00 sec)
首先看看這個表裡面有沒有
InnoDB | YES | Supports transactions, row-level locking, and foreign keys | YES | YES | YES
如果沒有就安裝innodb外掛程式
可以用 show engines;或者show plugins;來查看
MySQL> show plugins;+------------+--------+----------------+---------+---------+| Name | Status | Type | Library | License |+------------+--------+----------------+---------+---------+| binlog | ACTIVE | STORAGE ENGINE | NULL | GPL || CSV | ACTIVE | STORAGE ENGINE | NULL | GPL || MEMORY | ACTIVE | STORAGE ENGINE | NULL | GPL || MRG_MYISAM | ACTIVE | STORAGE ENGINE | NULL | GPL || MyISAM | ACTIVE | STORAGE ENGINE | NULL | GPL |+------------+--------+----------------+---------+---------+5 rows in set (0.00 sec)
方法一:
在configure的時候加上–with-plugins=innobase (或all) 如果要添多個外掛程式,用半形逗號隔開
方法二:
如果mysql已經編譯好了,又不想重新編譯,可以安裝外掛程式,innodb就是一個外掛程式,安裝好mysql後也是可以添加的。
1,查看一下,mysql配置是不是支援動態添加外掛程式
mysql> show variables like "have_%";+----------------------+-------+| Variable_name | Value |+----------------------+-------+| have_compress | YES || have_crypt | YES || have_csv | YES || have_dynamic_loading | YES | //在這裡是YES表示是支援的
如果是no呢,就不太好辦,因為have_dynamic_loading是唯讀變數,
mysql> set have_dynamic_loading=1;ERROR 1238 (HY000): Variable ‘have_dynamic_loading’ is a read only variable
不過一般情況下都是YES,
2,添加外掛程式
mysql> INSTALL PLUGIN INNODB SONAME ‘ha_innodb.so‘;
//提示打不開檔案,沒有許可權
找到安裝目錄下的/lib/mysql/plugin目錄,運行如下命令:
@ubuntu:/usr/local/mysql# chcon -t texrel_shlib_t /usr/local/mysql/lib/mysql/plugin/ha_innodb.so
其實用ll命令看一下,就可以發現ha_innodb.so是ha_innodb.so.0.0.0的連結,實在不行可以這樣執行:
install plugin INNODB soname "ha_innodb.so.0.0.0";
安裝以下幾個
mysql> install plugin INNODB soname "ha_innodb_plugin.so.0.0.0";mysql> install plugin INNODB_TRX soname "ha_innodb_plugin.so.0.0.0";mysql> install plugin INNODB_LOCKS soname "ha_innodb_plugin.so.0.0.0";mysql> install plugin INNODB_LOCK_WAITS soname "ha_innodb_plugin.so.0.0.0";mysql> install plugin INNODB_CMP soname "ha_innodb_plugin.so.0.0.0";mysql> install plugin INNODB_CMP_RESET soname "ha_innodb_plugin.so.0.0.0";mysql> install plugin INNODB_CMPMEM soname "ha_innodb_plugin.so.0.0.0";mysql> install plugin INNODB_CMPMEM_RESET soname "ha_innodb_plugin.so.0.0.0";
以上幾個命令我看有的達人引用的包是ha_innodb.so,但我執行了會說找不到INNODB_TRX ,我想會不會是這個包裡沒有,於是改用ha_innodb_plugin.so這個包就可以了。
安裝好後,在用 show engines;或者show plugins;來查看
mysql> show plugins;+---------------------+--------+--------------------+---------+---------+| Name | Status | Type | Library | License |+---------------------+--------+--------------------+---------+---------+| binlog | ACTIVE | STORAGE ENGINE | NULL | GPL || CSV | ACTIVE | STORAGE ENGINE | NULL | GPL || MEMORY | ACTIVE | STORAGE ENGINE | NULL | GPL || InnoDB | ACTIVE | STORAGE ENGINE | NULL | GPL || INNODB_TRX | ACTIVE | INFORMATION SCHEMA | NULL | GPL || INNODB_LOCKS | ACTIVE | INFORMATION SCHEMA | NULL | GPL || INNODB_LOCK_WAITS | ACTIVE | INFORMATION SCHEMA | NULL | GPL || INNODB_CMP | ACTIVE | INFORMATION SCHEMA | NULL | GPL || INNODB_CMP_RESET | ACTIVE | INFORMATION SCHEMA | NULL | GPL || INNODB_CMPMEM | ACTIVE | INFORMATION SCHEMA | NULL | GPL || INNODB_CMPMEM_RESET | ACTIVE | INFORMATION SCHEMA | NULL | GPL || MRG_MYISAM | ACTIVE | STORAGE ENGINE | NULL | GPL || MyISAM | ACTIVE | STORAGE ENGINE | NULL | GPL |+---------------------+--------+--------------------+---------+---------+13 rows in set (0.00 sec
mysql匯入報錯 ERROR 1286 (42000) at line 1: Unknown table engine 'InnoDB'