移植了一下mysql,相比之下比sqlite要大众一点关键是搞nodejs会用到,web什么的还是mysql主流,当然对于很多嵌入式应用sqlite足够了。
这个移植有点花时间,搞了大半天加上半个晚上,才弄好了。上传移植后的文件给大家玩,能做很多事情,比如和qt程序一起使用包含库和头文件就好了,直接用。
核心移植部分说明:
- 5)交叉编译MYSQL
- 1.1)配置configure
- # ./configure --host=arm-linux –-enable-static --with-named-curses-libs=/home/develop/helper2416/mysql/ncurses-5.6/ncurses-install/lib/libncurses.a
- --prefix=/usr/local/mysql --without-debug --without-docs --without-man --without-bench --with-charset=gb2312 --with-extra-charsets=ascii,latin1,utf8
- 这里注意libncurses.a库的安装目录,交叉编译的MYSQL也安装到了/usr/local/mysql,这个是因为我在编译PC版本的MYSQL时只是使用了make并没有make install.
- 如果你也需要使用ubuntu下面的MYSQL,并且当时使用了make install,这里就需要注意目录问题.
-
- 1.2)定义STACK_DIRECTION
- # vim sql/sql_parse.cc
- 在大约5432行添加
- #define STACK_DIRECTION 1
-
- 1.3)直接开始运行make编译源代码
- # make
- 出现错误:
- make[2]: Leaving directory 'xxx'
- ./gen_lex_hash > lex_hash.h-t /bin/sh:
- ./gen_lex_hash: cannot execute binary file
- 这个时候就需要将刚才我们编译好的PC版本的$MYSQL-PC\sql\目录下面的gen_lex_hash,然后cp到现在交叉编译时对应的$MYSQL-ARM\sql\目录覆盖即可.
- 注意,覆盖完成后不要急于make,这时输入如下命令:
- # touch –m sql/gen_lex_hash
- # make
- 上面的命令是改变gen_lex_hash的最后修改时间,这样做的目的是告诉编译器gen_lex_hash已经是最新的了,不要重新生成它.
- 否则编译器检查gen_lex_hash和它的依赖文件的最后修改时间会发现gen_lex_hash比它的依赖文件更旧,就会重新交叉编译生成它,这样不管我们做几次覆盖的工作错误都还会再现.
-
- 1.4)提示错误
- # vim Makefile
- 屏蔽如下内容:
- do_abi_check:
- # set -ex; \
- # for file in $(abi_headers); do \
- # arm-linux-gcc -E -nostdinc -dI -DMYSQL_ABI_CHECK \
- # -I$(top_srcdir)/include \
- # -I$(top_srcdir)/include/mysql \
- # -I$(top_srcdir)/sql \
- # -I$(top_builddir)/include \
- # -I$(top_builddir)/include/mysql \
- # -I$(top_builddir)/sql \
- # $file 2>/dev/null | \
- # /bin/sed -e '/^# /d' \
- # -e '/^[ ]*$/d' \
- # -e '/^#pragma GCC set_debug_pwd/d' \
- # -e '/^#ident/d' > \
- # $(top_builddir)/abi_check.out; \
- # /usr/bin/diff -w $file.pp $(top_builddir)/abi_check.out; \
- # /bin/rm $(top_builddir)/abi_check.out; \
- # done
- 1.5)最后执行安装命令即可,权限问题需要使用sudo
- # sudo make install
- 注意由于需要使用arm-linux-rainlib命令,所以需要使用export PATH='$PATH:/cross_compile_path'
复制代码
来看一下移植后运行的东西吧
版本测试:
启动mysql
运行mysql
mysql-help
mysql简单测试
说说配置吧,这个对新手来说也有点复杂,关键是要搞清楚调理性
一、准备工作
1、拷贝交叉编译好的文件夹到板子上对应的路径下,/usr/local/mysql目录下的bin/+libexec/+share/
2、修改相关执行文件的权限
3、将lib相关的库拷贝到板子中的lib目录下,注意只要个别,不需要全部。
二、ARM配置
1、将/usr/local/mysql/share/mysql/mysql.server拷贝到/etc/init.d/mysql.server
- # cp /usr/local/mysql/share/mysql/mysql.server /etc/init.d/mysql.server
复制代码
2、添加配置文件
- [mysqld]
- datadir=/usr/local/mysql/mysql_data
- socket=/tmp/mysql.sock
- user=root
- #Default to using old password format for compatibility with mysql 3.x
- #clients (those using the mysqlclient10 compatibility package).
- old_passwords=1
- [mysqld_safe]
- log-error=/var/log/mysqld.log
- pid-file=/var/lib/mysql/camelshoko.pid
复制代码
3、版本测试
- # mysql -V
- mysql Ver 14.14 Distrib 5.1.51, for unknown-linux-gnu (arm) using EditLine wrapper
复制代码
4、安装数据库
- # mysql_install_db -u root --force
复制代码
- Installing MySQL system tables...
- OK
- Filling help tables...
- OK
- To start mysqld at boot time you have to copy
- support-files/mysql.server to the right place for your system
- PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
- To do so, start the server, then issue the following commands:
- /usr/local/mysql/bin/mysqladmin -u root password 'new-password'
- /usr/local/mysql/bin/mysqladmin -u root -h localhost password 'new-password'
- Alternatively you can run:
- /usr/local/mysql/bin/mysql_secure_installation
- which will also give you the option of removing the test
- databases and anonymous user created by default. This is
- strongly recommended for production servers.
- See the manual for more instructions.
- You can start the MySQL daemon with:
- cd /usr/local/mysql ; /usr/local/mysql/bin/mysqld_safe &
- You can test the MySQL daemon with mysql-test-run.pl
- cd /usr/local/mysql/mysql-test ; perl mysql-test-run.pl
- Please report any problems with the /usr/local/mysql/bin/mysqlbug script!
复制代码
5、启动MySQL服务
- # /etc/init.d/mysql.server start
- Starting MySQL.. SUCCESS!
复制代码
6、MySQL测试
- # mysql
- Welcome to the MySQL monitor. Commands end with ; or \g.
- Your MySQL connection id is 1
- Server version: 5.1.51 Source distribution
- Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
- This software comes with ABSOLUTELY NO WARRANTY. This is free software,
- and you are welcome to modify and redistribute it under the GPL v2 license
- No entry for terminal type "vt100";
- using dumb terminal settings.
- Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
- mysql>
复制代码
后面会分享如何用nodejs+mysql搭建自己的家庭网关,节点暂时确定使用wifi+fr5969,我的板子也有移植了wifi了,可以直接交互数据。
usr-local-mysql.zip
(29.69 MB, 下载次数: 46)