When MySQL is compiled and installed, it is sometimes found that the InnoDB storage engine is not supported when the installation is complete, because the parameters that support InnoDB are missing when compiling the installation:
--with-plugins=PLUGIN[,PLUGIN..]Plugins to include in mysqld. (default is: none)Must be a configuration name or a comma separatedlist of plugins.Available configurations are: none max max-no-ndb all.Available plugins are: partition archive blackholecsv example federated heap ibmdb2i innobaseinnodb_plugin myisam myisammrg ndbcluster.--with-plugins=innobase 或者--with-plugins=all #这是在5.5版本前-DWITH_INNOBASE_STORAGE_ENGINE=1 #这是在5.5以后版本,用cmake编译时支持innodb所用的参数
However, those parameters should be selected at compile time and will not be helpful to the present problem; Here's how to add InnoDB support.
I. Dynamic load INNODB
See if MySQL supports InnoDB now
mysql> Show variables like "have_%"; +-------------------------+----------+| variable_name | Value |+-------------------------+----------+| Have_community_features | YES | | have_compress | YES | | Have_crypt | YES | | Have_csv | YES | | have_dynamic_loading | YES | | Have_geometry | YES | | Have_innodb | NO | | Have_ndbcluster | NO | | Have_openssl | DISABLED | | have_partitioning | NO | | Have_query_cache | YES | | Have_rtree_keys | YES | | Have_ssl | DISABLED | | Have_symlink | YES |+-------------------------+----------+14 rows in Set (0.00 sec)
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 || MyISAM | ACTIVE | STORAGE ENGINE | NULL | GPL || MRG_MYISAM | ACTIVE | STORAGE ENGINE | NULL | GPL |+------------+--------+----------------+---------+---------+5 rows in set (0.01 sec)#可见现在的mysql确实不支持innodb存储引擎
2. See if dynamic load plugins are supported
mysql> show variables like "have_dynamic%";+----------------------+-------+| Variable_name | Value |+----------------------+-------+| have_dynamic_loading | YES |+----------------------+-------+1 row in set (0.00 sec)#当现实为yes时表示支持动态加载mysql插件,该值一般为yes,当使用源码编译安装时不能使用–with-mysqld-ldflags=-all-static选项,以静态方式编译库,这样默认就会是yes。
3. Insert the plugin file
Find the MySQL Storage plugin directory
mysql> show variables like ‘plugin_dir‘;+---------------+-----------------------------+| Variable_name | Value |+---------------+-----------------------------+| plugin_dir | /opt/mysql/lib/mysql/plugin |+---------------+-----------------------------+1 row in set (0.00 sec)#在该目录中查看是否已有ha_innodb.so和ha_innodb_plugin.so两个文件[[email protected] mysql-5.1.39]# ll /opt/mysql/lib/mysql/plugin/ha_innodb.solrwxrwxrwx 1 mysql mysql 18 08-22 02:55 /opt/mysql/lib/mysql/plugin/ha_innodb.so -> ha_innodb.so.0.0.0[[email protected] mysql-5.1.39]# ll /opt/mysql/lib/mysql/plugin/ha_innodb_plugin.solrwxrwxrwx 1 mysql mysql 25 08-22 02:55 /opt/mysql/lib/mysql/plugin/ha_innodb_plugin.so -> ha_innodb_plugin.so.0.0.0#若没有可以去网上下载与所安装mysql对应的版本,或者直接去mysql源码包中storage/innobase/.libs/ha_innodb.sostorage/innodb_plugin/.libs/ha_innodb_plugin.so 复制到mysql的plugin目录中
4. Add Dynamic Install Load
mysql> INSTALL PLUGIN InnoDB SONAME ‘ha_innodb.so‘;Query OK, 0 rows affected (0.61 sec)
5. See if InnoDB is currently supported
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 | | MyISAM | ACTIVE | STORAGE ENGINE | NULL | GPL | | Mrg_myisam | ACTIVE | STORAGE ENGINE | NULL | GPL | | InnoDB | ACTIVE | STORAGE ENGINE | ha_innodb.so | GPL |+------------+--------+----------------+--------------+---------+6 rows in Set (0.01 sec) mysql> Show engines;+ ------------+---------+------------------------------------------------------------+--------------+------+----- -------+| Engine | Support | Comment | Transactions | XA | savepoints |+------------+---------+------------------------------------------------------------+--------------+------+------------+| CSV | YES | CSV Storage Engine | NO | NO | NO | | InnoDB | YES | Supports transactions, Row-level locking, and foreign keys | YES | YES | YES | | 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 | | Mrg_myisam | YES | Collection of identical MyISAM tables | NO | NO | NO |+------------+---------+------------------------------------------------------------+--------------+------+ + -----------+5 rows in Set (0.01 sec)
Two: Append compilation
1. Remove InnoDB support and view
mysql> UNINSTALL PLUGIN InnoDB; Query OK, 0 rows affected (0.52 sec) mysql> Show 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)
2. Recompile the installation
。。。。。。
Mysql Add InnoDB Support