移植Mysql到ARM平台

移植Mysql到ARM平台

目前我使用的Mysql的版本为mysql-5.1.72.tar.gz,可在网上下载对应版本的mysql的压缩包。由于移植mysql库需要用到libncurses.a静态库,所以在移植mysql之前,我们需要先移植ncurses,目前我使用的ncurses库版本为ncurses-5.9.tar.gz,以下是移植ncusrse库的步骤:
(1)解压库文件:
tar zxvf ncurses-5.9.tar.gz -C /opt/mysql/ncurses(2)进入库文件路径,配置环境变量:
CC=arm-linux-gnueabihf-gcc ./configure –host=arm-linux-gnueabihf -prefix=/opt/mysql/ncurse –enable-static
(3)编译、安装:
make
make install
安装ncurses库时出现问题:arm-linux-ranlib command not found
解决办法: 先用下sudo -i命令取得root权限。然后再执行make install。
由于移植mysql需要用到一个本地编译的文件gen_lex_hash,所以需要先本地编译mysql,操作如下:
在./configure前需要屏蔽部分代码,否则配置环境变量会出错,无法配置,
vi ./configure,该文件应该有这样的代码“ if test “$cross_compiling” = yes; then { { a s e c h o " as_echo " asecho"as_me:KaTeX parse error: Can't use function '\`' in math mode at position 19: …ENO: error: in \̲`̲ac_pwd’:" >&5 a s e c h o " as_echo " asecho"as_me: error: in `$ac_pwd’:" >&2;}
{ { a s e c h o " as_echo " asecho"as_me:$LINENO: error: cannot run test program while cross
compiling See `config.log’ for more details." >&5 a s e c h o " as_echo " asecho"as_me: error: cannot run test program while cross compiling See `config.log’ for more details." >&2;}
{ (exit 1); exit 1; }; }; }
Else

将此代码改为“将这些代码改为:
if test “$cross_compiling” = yes; then
echo “skip ……!”
#{ { a s e c h o " as_echo " asecho"as_me:KaTeX parse error: Can't use function '\`' in math mode at position 19: …ENO: error: in \̲`̲ac_pwd’:" >&5 # a s e c h o " as_echo " asecho"as_me: error: in `$ac_pwd’:" >&2;}
#{ { a s e c h o " as_echo " asecho"as_me:KaTeX parse error: Can't use function '\`' in math mode at position 66: … compiling See \̲`̲config.log' for…as_echo “$as_me: error: cannot run test program while cross compiling See `config.log’ for more details.” >&2;}
#{ (exit 1); exit 1; }; }; }
Else

这样的代码总共有四处,都要屏蔽掉,分别在26302,48120,48226,48439行。

CC=gcc ./configure --prefix=/opt/mysql/mysql
make
不需要make install
本地编译此版本的mysql没有出错,然后交叉编译,操作如下:
(1)./configure --prefix=/opt/mysql/mysql --host=arm-linux-gnueabihf CC=arm-linux-gnueabihf-gcc --enable-static --enable-shared
安装mysql时出现:configure: error: No curses/termcap library found
若是安装以下后仍然 .configure 后出现上面问题:
sudo apt-cache search ncurses
sudo apt-get install libncurses5-dev
采用如下配置,重新.configure,即可通过:
./configure --host=arm-linux-gnueabihf --enable-static --with-named-curses-libs=/opt/mysql/ncurses/lib/libncurses.a --prefix=/opt/mysql/mysql --without-debug --without-docs --without-man --without-bench --with-charset=gb2312 --with-extra-charsets=ascii,latin1,utf8

(2)make
make 出现错误:
make[2]: Leaving directory `/opt/mysql-5.5.3-m3/sql’
./gen_lex_hash > lex_hash.h-t
/bin/sh: ./gen_lex_hash: cannot execute binary file
解决办法:
需要将刚才我们编译好的本地版本的sql\目录下面的gen_lex_hash,拷贝到现在交叉编译时对应的sql\目录覆盖即可;
覆盖完成后输入如下命令:
root@ubuntu:/opt/lib/mysql-5.1.51# touch –m sql/gen_lex_hash
再次make应该又会出现新的问题:
make 出现问题:
sql_parse.cc:5432:21: operator ‘<’ has no left operand
解决办法:
由于宏变量STACK_DIRECTION没有定义初值,所以找到sql_parse.cc文件,将第5444行的前面一行加入#define STACK_DIRECTION 1
之后再次make即可编译通过;
(3)make install
搭建环境,本文档只提供mysql安全模式下操作登陆操作mysql。
安装完成后,将安装后的文件打包拷贝到arm板上对应的目录下进行解压;
进入解压的目录的bin文件下
cd /opt/mysql/mysql/bin
mysqld_safe --skip-grant-tables &
现在应该可以登陆mysql,
mysql -u root -p123456
具体登陆操作mysql,可网上搜索,移植mysql完成。

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值