工做中,難免會遇到前輩已經編譯安裝過的mysql,突然發現mysql不支持innodb的存儲引擎的問題,如今來看一下吧
mysql
1、先看mysql是否支持innodb存儲引擎sql
mysql> show variables like 'ha%';bash
+----------------------+----------+ide
| Variable_name | Value |spa
+----------------------+----------+插件
| have_compress | YES |code
| have_crypt | YES |orm
| have_csv | YES |ssl
| have_dynamic_loading | YES |ci
| have_geometry | YES |
| have_innodb | DISABLED |
| have_ndbcluster | NO |
| have_openssl | DISABLED |
| have_partitioning | YES |
| have_profiling | YES |
| have_query_cache | YES |
| have_rtree_keys | YES |
| have_ssl | DISABLED |
| have_symlink | YES |
+----------------------+----------+
14 rows in set (0.00 sec)
have_innodb:值爲DISABLED,表示未啓用,值爲no,表示不支持innodb存儲引擎
mysql> show plugins;
+-----------------------+----------+----------------+---------+---------+
| Name | Status | Type | Library | License |
+-----------------------+----------+----------------+---------+---------+
| binlog | ACTIVE | STORAGE ENGINE | NULL | GPL |
| mysql_native_password | ACTIVE | AUTHENTICATION | NULL | GPL |
| mysql_old_password | ACTIVE | AUTHENTICATION | NULL | GPL |
| MEMORY | ACTIVE | STORAGE ENGINE | NULL | GPL |
| MRG_MYISAM | ACTIVE | STORAGE ENGINE | NULL | GPL |
| CSV | ACTIVE | STORAGE ENGINE | NULL | GPL |
| MyISAM | ACTIVE | STORAGE ENGINE | NULL | GPL |
| BLACKHOLE | ACTIVE | STORAGE ENGINE | NULL | GPL |
| FEDERATED | DISABLED | STORAGE ENGINE | NULL | GPL |
| PERFORMANCE_SCHEMA | ACTIVE | STORAGE ENGINE | NULL | GPL |
| ARCHIVE | ACTIVE | STORAGE ENGINE | NULL | GPL |
| partition | ACTIVE | STORAGE ENGINE | NULL | GPL |
+-----------------------+----------+----------------+---------+---------+
如今的mysql的確不支持innodb存儲引擎
2.查看是否支持動態加載插件
mysql> show variables like 'have_dynamic%';
+----------------------+-------+
| Variable_name | Value |
+----------------------+-------+
| have_dynamic_loading | YES |
+----------------------+-------+
1 row in set (0.00 sec)
have_dynamic_loading:值爲yes,表示動態加載mysql的插件
當使用源碼編譯安裝時不能使用-with-mysqld-ldflags=all-static選項
3.放入插件文件,找到mysql存放插件的路徑
mysql> show variables like 'plugin_dir';
+---------------+------------------------------+
| Variable_name | Value |
+---------------+------------------------------+
| plugin_dir | /usr/local/mysql/lib/plugin/ |
+---------------+------------------------------+
#在該目錄中查看是否已有ha_innodb.so和ha_innodb_plugin.so兩個文件
[root@zhu2 mysql-5.1.39]
# ll /usr/local/mysql/lib/plugin/ha_innodb.so
lrwxrwxrwx 1 mysql mysql 18 08-22 02:55
/opt/mysql/lib/mysql/plugin/ha_innodb
.so -> ha_innodb.so.0.0.0
[root@zhu2 mysql-5.1.39]
# ll /usr/local/mysql/lib/plugin/ha_innodb_plugin.so
lrwxrwxrwx 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.so
storage
/innodb_plugin/
.libs
/ha_innodb_plugin
.so 複製到mysql的plugin目錄中
4.添加動態安裝加載
mysql> INSTALL PLUGIN InnoDB SONAME
'ha_innodb.so'
;
Query OK, 0 rows affected (0.61 sec)
5.看如今是否支持innodb
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)
2、追加編譯
1.刪除innodb支持,應查看
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.從新編譯
注:注意mysql的編譯安裝方式,
2.看mysql不支持或者未啓用innodb存儲引擎