[原创]移植常用软件到MIPS平台之mysql5
1.平台环境:BCM3302 V2.9
2.移植软件:mysql5(下载:mysql-5.0.22.tar.gz)
3.移植目标:
能在目标平台上正常以后台进程方式运行
能正常查询,建立数据等日常数据库操作
4.移植说明:
CXX 必须指定C++的编译器,否则configure即出错
一、编译环境的建立
——————————————————————————
- export CXX=/usr/local/hndtools-mipsel-uclibc-4.2.4/bin/mipsel-linux-g++
- export CPPFLAGS='-s -static -I/usr/local/hndtools-mipsel-uclibc-4.2.4/include'
- export CFLAGS='-s -static -I/usr/local/hndtools-mipsel-uclibc-4.2.4/include'
- export LDFLAGS=-L/usr/local/hndtools-mipsel-uclibc-4.2.4/lib/
- export CC=/usr/local/hndtools-mipsel-uclibc-4.2.4/bin/mipsel-linux-gcc
- export AR=/usr/local/hndtools-mipsel-uclibc-4.2.4/bin/mipsel-linux-ar
- export LD=/usr/local/hndtools-mipsel-uclibc-4.2.4/bin/mipsel-linux-ld
- export RANLIB=/usr/local/hndtools-mipsel-uclibc-4.2.4/bin/mipsel-linux-ranlib
二、建立配置文件
——————————————————————————
- ./configure --prefix=/linuxany.com/cross/mysql --host=mips-linux --with-named-curses-libs=/mnt/usb1_1/mips_ncurses/lib/libncurses.a --without-debug --without-docs --without-man --without-bench --with-mysqld-ldflags=-all-static --with-client-ldflags=-all-static
出错解决:
1、return type of sprintf : error: cannot run test program while cross compiling
检查configure脚本,发现脚本在检测到在做cross-compile时就提示以上错误并退出,说明至少是这个版本的mysql并不支持交叉编译,但用了最新的版本试了也还是有同样的错误,基本可以肯定mysql还没有支持交叉编译的版本出现.但为了让编译继续,我在configure脚本中将多处这样的命令全都注释掉以让configure通过,注意这个有多处。
2、error: C++ preprocessor “/lib/cpp” fails sanity check
(1)安装 mipsel-linux-g++ 编译器
(2)指定 CXX 环境变量
3、error: Your compiler cannot convert a longlong value to a float!
这个问题在较低版本的mysql中是一个bug,但5.0的版本已经修复了这个问题,可考虑将编译器更新到较新的版本再试,暂无其它可行的跳过办法。
4、/usr/lib/libncurses.a: could not read symbols: File in wrong format
编译一个ncurses到mips平台即可,./configure时用参数指定–with-named-curses-libs=/linuxany.com/cross/mips_ncurses/lib/libncurses.a
5、/bin/bash: ./gen_lex_hash: cannot execute binary file
编译一个pc平台的gen_lex_hash,然后cp到$MYSQL\sql\目录覆盖即可
三、初始化数据库
——————————————————————————
./mysql_install_db –user=root
Neither host ‘LINUXANY-CROSS’ nor ‘localhost’ could be looked up with
/linuxany.com/cross/mysql/bin/resolveip
Please configure the ‘hostname’ command to return a correct hostname.
If you want to solve this at a later stage, restart this script with
the –force option.
解决办法:取下面其一能解决就行,不需要全部执行
(1)echo “192.168.100.100 LINUXANY-CROSS” >> /etc/hosts
(2)hostname 192.168.100.100
(3)./mysql_install_db –user=root –force
四、服务运行
——————————————————————————
启动服务:
cd /linuxany.com/cross/mysql ;
/linuxany.com/cross/mysql/bin/mysqld_safe –user=root &
出错解决:
# /linuxany.com/cross/mysql/bin/mysqld_safe: 1: grep: not found
/linuxany.com/cross/mysql/bin/mysqld_safe: 1: grep: not found
/linuxany.com/cross/mysql/bin/mysqld_safe: 1: grep: not found
/linuxany.com/cross/mysql/bin/mysqld_safe: 1: tee: not found
/linuxany.com/cross/mysql/bin/mysqld_safe: 1: tee: not found
date: invalid date `+%y%m%d %H:%M:%S’
解决办法:编译相关的命令sed,grep,tee到mips平台,并加入到PATH中,其中sed,grep命令必须存在,否则数据库在查询时一样会出错。
# /linuxany.com/cross/mysql/bin/mysqld_safe –user=root &
# chown: invalid user: `root’
Starting mysqld daemon with databases from /linuxany.com/cross/mysql/var
date: invalid date `+%y%m%d %H:%M:%S mysqld started’
解决办法:这个是由于挂载的分区格式引起的,如为FAT32/NTFS格式即会出此问题,但不影响服务运行
五、安全设置
——————————————————————————
(1)设置root密码
/linuxany.com/cross/mysql/bin/mysqladmin -u root password ‘linuxany.com’
/linuxany.com/cross/mysql/bin/mysqladmin -u root -h LINUXANY-CROSS password ‘linuxany.com’
(2)设置远程连接
mysql -uroot -plinuxany.com
grant all on *.* to linuxany@’%’ identified by ‘linuxany.com’;
2条评论▼