Use of MySQL InnoDB on openwrt and related anomalies

Source: Internet
Author: User

MySQL is first configured in Menuconfig, specifically in Utilities->database->mysql-server. This can be compiled directly, but this default is not supported by the INNODB storage engine, it is estimated that the openwrt is generally run by the hardware concerned, do not need such a complex storage engine (space is also larger than the MyISAM storage engine). But what if you need to support the InnoDB storage engine? This type of online posts are not many, I was before referring to foreign forums plus their own testing.

OpenWrt supports InnoDB storage engine
Modify Feeds/oldpackages/libs/mysql/makefile
Add--with-innodb before the--with-server

Modify FEEDS/OLDPACKAGES/LIBS/MYSQL/CONF/MY.CNF
Add Default-storage-engine=innodb in [mysqld]
In bind-address = 127.0.0.1 Download add
InnoDB
innodb_file_per_table = 1
Innodb_flush_log_at_trx_commit = 2

The/etc/init.d/mysqld script start function is added

Start () {Local datadir=$ (Sed-n-E "s/^[[:space:]]*datadir[[:space:]]*=[[:space:]]*[\" ']\?\ ([^\] ']*\ ') [\ ' ']\?/\1/p '/         ETC/MY.CNF) Local mysqldatadir= "/mnt/data/mysql/" local mysqltmpdir= "/mnt/data/tmp/" local mysqlsrvdir= "/srv/mysql/" if [!-D "$mysqldatadir"]; Then echo "Create dir/mnt/data/mysql/..." mkdir-p "$mysqldatadir" fi if [! -D "$mysqltmpdir"]; Then echo "Create dir/mnt/data/tmp/..." mkdir-p "$mysqltmpdir" fiif [! -D "$mysqlsrvdir"]; Then echo "Create dir/srv/mysql/..." mkdir-p "$mysqlsrvdir" fiif [! -D "$datadir"]; Thenerror "Error:datadir ' $datadir ' in/etc/my.cnf doesn ' t exist" return 1FIIF [!-F "$datadir/mysql/tables_priv. MYD "]; thenmysql_install_db--forceservice_stop/usr/bin/mysqld#error "error:i didn ' t detect a privileges table, you might need To run mysql_install_db--force to initialize the system tables "#return 1fiservice_start/usr/bin/mysqld}
At this point, InnoDB-based MySQL will work.
On NETGEAR3700V2 hardware-based openwrt, there will be an initialization InnoDB, the exception is the creation of a socket failure, prompt such as can ' t connect to local MySQL server through socket '/ Var/run/mysqld/mysqld.sock '. In fact, this is due to the initialization of InnoDB failure, because netgear3700v2 flash only 16M, can not meet the requirements of InnoDB, data file size sum of at least ten MB. You may print a message similar to the following by typing the mysqld--skip-grant& command:
[Email protected]_ap:/# mysqld--skip-grant&
[Email protected]_ap:/# 150203 1:32:31 innodb:initializing buffer pool, size = 8.0M
150203 1:32:31 innodb:completed initialization of buffer pool
innodb:error:auto-extending data file./ibdata1 is of a different size
innodb:64 pages (rounded to MB) than specified in the. cnf file:
Innodb:initial 640 pages, Max 0 (relevant if non-zero) pages!
Innodb:could not open or create data files.
Innodb:if tried to add new data files, and it failed here,
Innodb:you should now edit Innodb_data_file_path on my.cnf back
Innodb:to what it is, and remove the new ibdata files InnoDB created
Innodb:in this failed attempt. InnoDB only wrote those files full of
Innodb:zeros, but does not yet the use of them in any. But being careful:do not
Innodb:remove old data files which contain your precious data!
150203 1:32:31 [ERROR] Plugin ' InnoDB ' init function returned ERROR.
150203 1:32:31 [ERROR] Plugin ' InnoDB ' registration as a STORAGE ENGINE failed.
150203 1:32:31 [ERROR] unknown/unsupported table Type:innodb
150203 1:32:31 [ERROR] Aborting

150203 1:32:31 [Note] Mysqld:shutdown complete

The above puzzling problem is verified by the fact that the flash space is not enough. The workaround is to mount a USB flash drive on the router. The configuration items for mounting the USB drive are:
Kernel Modules->filesystems->kmod-fs-vfat
Kernel modules->native language Support->kmod-nls-cp437/kmod-nls-iso8859-1/kmod-nls-utf-8
Kernel Modules->usb SUPPORT->KMOD-USB-CORE/KMOD-USB-OHCI/KMOD-USB-STORAGE/KMOD-USB-USB2

Also, in init initialization scripts, if multiple MySQL operations are executed sequentially, such as mysql_install_db--force command and then mysqladmin-u root password ' 123456 ' may fail, Because you haven't waited for the mysql_install_db execution to complete the mysqladmin command. The solution to this problem is to add sleep time, depending on how long it takes.

Use of MySQL InnoDB on openwrt and related anomalies

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.