构建最小linux 文件系统----mysql 服务器移植

mysql 服务器移植

1.下载mysql5.1.73
http://www.mirrorservice.org/sites/ftp.mysql.com/Downloads/MySQL-5.1
2. 编译PC版本的mysql备用

a) 解压mysql-5.1.73到/opt/mysql-5.1.73: tar zxvf mysql-5.1.73.tar.gz

b) cd mysql-5.1.73

c) ./configure -prefix=/usr/local/mysql

d) make 注意,这里无需运行make install,以为主要是为了用pc版本里的gen_lex_hash库。(注意一定要先make后,再去修改文件夹名称)

e) 将文件夹mysql-5.1.73改名为mysql-5.1.73-pc备用。(将gen_lex_hash单独备份保存一下)

3. 编译arm版本的ncurses
a) 下载ncurses-5.6.tar.gz
http://ftp.gnu.org/pub/ncurses
b) tar zxvf ncurses-5.6.tar.gz
c) cd ncurses-5.6
d) ./configure –host=arm-linux -prefix=/usr/local/ncurse –enable-static
e) make
f) make install之所以安装这个,是因为对mysql的交叉编译过程需要该库的支持
(此步在用sudomake install时出错,原因是环境变量和原来不同了,解决办法:sudo -i;makeinstall )

4.编译arm版本的mysql
a) tar zxvf mysql-5.1.73.tar.gz
b) cd mysql-5.1.73
c) 修改配置文件:打开configure,可以使用geditconfigure:

        if test "$cross_compiling" =yes; then

        { { $as_echo "$as_me:$LINENO:error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in\`$ac_pwd':" >&2;}

        { { $as_echo "$as_me:$LINENO:error: cannot run test program while cross

        compiling See \`config.log' for moredetails." >&5

        $as_echo "$as_me: error: cannotrun test program while cross compiling See \`config.log' for moredetails." >&2;}

        {(exit 1); exit 1; }; }; }

        Else

将这些代码改为(这样的代码有4部分,要全部改掉):

if test"$cross_compiling" = yes;  then

echo "skip !!!"

        #{ { $as_echo "$as_me:$LINENO:error: in \`$ac_pwd':" >&5 #$as_echo "$as_me: error: in\`$ac_pwd':" >&2;}

        #{ { $as_echo "$as_me:$LINENO:error: cannot run test program while cross compiling See \`config.log' for moredetails." >&5

        #$as_echo "$as_me: error: cannotrun test program while cross compiling See \`config.log' for moredetails." >&2;}

        #{ (exit 1); exit 1; }; }; }

Else

d) 配置,直接套用了人家的配置方式:

./configure --host=arm-linux --enable-static --with-named-curses-libs=/usr/local/ncurse/lib/libncurses.a --prefix=/usr/local/mysql --without-debug --without-docs --without-man --without-bench --with-charset=gb2312 --with-extra-charsets=ascii,latin1,utf8

e) 修改opt/mysql-5.1.73/sql/sql_parse.cc:在5741行之前添加#define STACK_DIRECTION 1 ,如果不修改该语句,则会出现如下错误:sql_parse.cc:5646:21:operator ‘<’ has no left operand,原因是宏变量STACK_DIRECTION没有定义初值,arm中定义STACK_DIRECTION为1。

注意:这里的“#define STACK_DIRECTION 1”一句,不能随便加在sql_parse.cc的开头处,而应该根据出错信息的提示添加在相应的行上,我所遇到的行号和别人文档上所遇到的行号并不相同。
f) 复制PC版本的gen_lex_hash文件到当前文件夹:

       cp  {dir}/mysql-5.1.73-pc/sql/gen_lex_hash sql/

       touch –m sql/gen_lex_hash 

       cp  {dir}/mysql-5.1.73-pc/sql/ lex_hash.h sql/

       touch –m sql/lex_hash.h

g) Make
h) Make install

5.移植到arm 开发板

sudo cp -r /usr/local/mysql nfsroot/rootfs/usr/local/

cp mysql-5.1.73/support-files/mysql.server nfsroot/rootfs/etc/init.d/mysqld

开启mysqld服务

首先将以下内容保存为/etc/my.conf


[mysqld]

datadir=/var/lib/mysql

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/run/mysqld/mysqld.pid

6.启动开发板

cd /usr/local/mysql/bin/
./mysql_install_db -u root --force
cd /etc/init.d/
./mysqld start
Starting MySQL. SUCCESS!
cd /usr/local/mysql/bin# 
./mysql -u root -p

root@hostname:/usr/local/mysql/bin# ./mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.1.73-log Source distribution

Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

No entry for terminal type "vt102";
using dumb terminal settings.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值