移植MySQL到TX2

之前做的一个项目,把现有的liunx系统下的项目移植到TX2,前期项目移植还算顺利,到MySQL本来以为挺简单,交叉编译下就好,没想到用了整整两天,踩了无数的坑,现将步骤分享下,希望能对遇到相同问题的同学有所帮助。


 进行如下步骤完成移植:

1) 准备软件mysql5.1.73 
   

2) 安装编译器:用的是4.3.2的交叉编译器。gcc之类的都是ubuntu10.10自带的


3) 编译arm版本的ncurses 
    a) 准备ncurses-6.0.tar.gz  

    b) 解压到/opt/中:tar zxvf ncurses-6.0.tar.gz 

    c) cd ncurses-6.0 
    d) ./configure –host=arm-linux -prefix=/usr/local/ncurse –enable-static 

    e) make 
    f) make install
之所以安装这个,是因为对mysql的交叉编译过程需要该库的支持

      (此步在用sudo make install时出错,原因是环境变量和原来不同了,解决办法:sudo -imake install 

 

5) 编译arm版本的mysql 
    a) tar zxvf mysql-5.1.73.tar.gz 

    b) cd mysql-5.1.73 
    c) 
修改配置文件:打开configure,可以使用gedit configure 分别在第26453行、 48175行、 48282行、 48485行附近(上面的行号只是大概位置,具体位置还是以查找为准)有类似代码: 
        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 more details." >&5 

        $as_echo "$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 …..!” 

        #{ { $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 more details." >&5 
        #$as_echo "$as_me: error: cannot run test program while cross compiling See \`config.log' for more details." >&2;} 
        #{ (exit 1); exit 1; }; }; } 

        Else 

一定注意,这样的代码有4部分,要全部改掉 
    d) 
配置方式:

      ./configure --build=arm-linux --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

Libncurses.a的路径还是以实际查找的路径为准。

           

   c) Make 

   d) Make install 


6) 移植相应文件到ARM平台 
 
   a) 
到源码中拷贝配置文件模版  Copies files from one location to another. 配置文件模版) 

       cp /opt/mysql-5.1.73/support-files/my-medium.cnf  /usr/local/mysql /etc/my.cnf        

数据目录是在:/var/lib/mysql (默认)不需要修改

       安装目录是在:/usr/local/mysql (默认)不需要修改
        
    b) 
运行mysql_install_db
       cd /usr/local/mysql/bin
(开发板路径),

       mysql_install_db --user=root --force --basedir=/usr/local/mysql --datadir=/usr/local/mysql/var/lib/mysql (我修改了datadir的路径
         
       f) 
到源码中拷贝启动文件 
        cp /opt/mysql-5.1.51/support-files/mysql.server  /usr/local/mysql /etc/init.d/mysqld 

       修改该mysqld 

       加上了basedirdatadir

       还有pid-file=/tmp/mysqld.pid 

       还有service-pid-file=/tmp/mysqld.pid 

       修改完后,要给新的mysqld附以足够的权限: Chmod +x mysqld 
    g) 
在开发板开启MySQL服务 
       
开发板不支持service指令,所以service mysql start无效。

       采用的方法是运行./etc/init.d/mysqld start 
       
但最初运行该指令后出现下面的错误: 
       Starting MySQL... ERROR! Manager of pid-file quit without updating file. 
       
困扰我好久,到开发板目录/var/lib/mysql下查阅错误日志文件[hostname].err,在我的系统中该错误日志文件为EmbedSky.err,从中看到下面的记录: 
      150713 21:04:49 [ERROR] Fatal error: Can't change to run as user 'mysql' ;  Please check that the user exists! 
     
可能的原因是:在armlinux上无法执行groupadd mysql,因此需要采用如下方法解决该问题: cd /usr/local/mysql/var/lib/mysql 

 

 ls –la可以看到里面的属性中没有mysql,于是使用下面的命令: adduser mysql 
      chown mysql:mysql -R /var/lib/mysql 
     
然后开启mysql服务,还是出现了ERROR! Manager of pid-file quit without updating file.又查看EmbedSky.err日志,其中多了一条: 
      150714  2:48:04 [ERROR] Can't start server: Bind on TCP/IP port: Address already in use 
      150714  2:48:04 [ERROR] Do you already have another mysqld server running on port: 3306 ? 
     
很显然是因为已经有mysql的进程尝试打开3306端口,因此就被占用了,需要杀进程,索性重启开发板,然后运行./etc/init.d/mysqld start,可以完美打开。 

我使用的时候,错误不一样需要添加日志打印功能 /usr/local/mysql /etc/my.cnf中添加log-error=/tmp/error.log,根据错误提示解决错误问题,下面是我安装的时候出现的错误及解决办法。

打开日志

171013 10:50:19 mysqld_safe Starting mysqld daemon with databases from usr/local/mysql/var/lib/mysql

171013 10:50:19 [Warning] '--skip-locking' is deprecated and will be removed in a future release. Please use '--skip-external-locking' instead.

171013 10:50:19 [Warning] '--skip-locking' is deprecated and will be removed in a future release. Please use '--skip-external-locking' instead.

/usr/local/mysql/libexec/mysqld: File './mysql-bin.index' not found (Errcode: 13)

171013 10:50:19 [ERROR] Aborting

171013 10:50:19 [Note] /usr/local/mysql/libexec/mysqld: Shutdown complete

171013 10:50:19 mysqld_safe mysqld from pid file /tmp/mysqld.pid ended

发现找不到mysql-bin.index文件,应该是data目录没有权限造成的。

运行 chown -R mysql:mysql /usr/local/mysql/var/lib/mysql

重启MySQL搞定。
 

7) 测试ARM平台下的MySQL 
    a) mysqladmin -u  root   password  111111 最后一项为我的密码   (设置密码) 

    b) mysql  -u root  -p  这样便可以进入mysql环境。 

    c) mysql>show databases;

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值