mysql-5.1.73 数据库在AM335X上移植
一定注意编译AM335x上运行的mysql时要用下面编译器去编译:arm-arago-linux-gnueabi-
ncurses-5.9.tar.gz安装:
./configure -host=arm-arago-linux-gnueabi -prefix=/usr/local/ncurse -enable-static
512 make
513 make install
/
*******************************************************************************************************************/
begin
1、下载与解压mysql-5.1.73
分享一个下载地址:
http://pan.baidu.com/s/1bovivmv 提取码:8kct
将下载好的文件放到自定一个目录下
本人放到了:/home/voip_server_am335x_project/app/app/mysql/目录下了
解压mysql-5.1.73.zip
#unzip mysql-5.1.73.zip
2、编译PC版本的mysql备用
先将它复制一个并重命名
#cp -rfa mysql-5.1.73 pc-mysql-5.1.73
#cd pc-mysql-5.1.73
#./configure -prefix=/usr/local/mysql
#make
make 注意,这里无需运行make install,以为主要是为了用pc版本里的gen_lex_hash库。
3、编译ARM版本的mysql
先将它重命名
#cd ..
#mv mysql-5.1.73 arm-mysql-5.1.73
#cd arm-mysql-5.1.73
在配置前要修改一下配置文件:打开configure。
将如下代码:
if test “
cross_compiling” = yes; then
{ { $as_echo "$as_meLINENO: error: in `$ac_pwd’:” >&5
$as_echo "$as_me: error: in `$ac_pwd’:” >&2;}
{ { $as_echo "$as_meLINENO: 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 …..!”
else
要改四处这样的地方
修改configure将如下代码:
26302 #if test “
cross_compiling” = yes; then
26303 # { { $as_echo "$as_me:$LINENO: error: in `$ac_pwd’:” >&5
26304 #$as_echo "$as_me: error: in `$ac_pwd’:” >&2;}
26305 #{ { $as_echo "$as_me:$LINENO: error: cannot run test program while cross compiling
26306 #See `config.log’ for more details.” >&5
26307 #$as_echo "$as_me: error: cannot run test program while cross compiling
26308 #See `config.log’ for more details.” >&2;}
26309 # { (exit 1); exit 1; }; }; }
26310 #else
改为:
if test “cross_compiling” = yes;then
echo “skip….!”
else
还有3处: 48120行48226行48439行
改完后:
./configure –host=arm-arago-linux-gnueabi –prefix=/usr/local/mysql LDFLAGS=-L/usr/share/ncurses/lib/ CPPFLAGS=-I/usr/share/ncurses/include/ –without-debug –without-docs –without-man –without-bench –with-charset=gb2312 –with-extra-charsets=ascii,latin1,utf8
参考:./configure –host=arm-arago-linux-gnueabi –-enable-static –with-named-curses-libs=/usr/local/ncurses/lib/libncurses.a –prefix=/usr/local/mysql –without-debug –without-docs –without-man –without-bench –with-charset=gb2312 –with-extra-charsets=ascii,latin1,utf8
配置(这里会用到以前在移植htop-1.0.2工具时编译过的ncurses)
#make
编译
#make
出现错误
make[2]: Leaving directory `/home/zhaowg/mysql-pc/sql'
./gen_lex_hash > lex_hash.h-t
/bin/sh: ./gen_lex_hash: cannot execute binary file
make[1]: *** [lex_hash.h] 错误 126
这是由于编译的 arm 类型的程序不能在 PC 上运行造成的,于是前面做的准备工作派上用场了:
# cp ../mysql-pc/sql/gen_lex_hash sql/
# touch -m sql/gen_lex_hash
出现错误:
sql_parse.cc:5432:21: operator ‘<’ has no left operand
解决办法:
这是由于宏变量STACK_DIRECTION没有定义初值,网上查找资料发现arm中定义STACK_DIRECTION为1,所以找到sql_parse.cc文件,将第5432行的前面一行加入#define STACK_DIRECTION 1
/opt/mysql/bin/my_print_defaults: line 1: syntax error: unexpected word (expecting “)”)
my_print_defaults是编译得到的可执行程序,怎么可能会有语法错误,百思不得其解,经过检索发现了一些线索
http://www.unix.com/shell-programming-scripting/103528-syntax-error-word-unexpected-expecting.html
不同的shell脚本对文件的解析有语法上的不同,而这种不同正能引发类似的这种错误
于是检查开发板和主机系统的shell
主机 :/bin/sh -> bash
开发板:/bin/sh -> busybox
于是对主机环境的sh更改连接,安装busybox,使得主机的sh -> busybox
重新对ncurses和myql编译,然后重新安装,结果顺利!!
保存退出
# make
# make install
4、移植到目标板上
将/usr/local 目录下的 mysql 文件夹拷贝到目标板的/usr/local 目录下。
在/etc/profile下添加环境变量。
export PATH=”
PATH:/usr/local/mysql/bin”exportLDLIBRARYPATH=”LD_LIBRARY_PATH:/usr/local/mysql/lib/mysql”
在目标板创建配置文件/etc/my.cnf
修改文件为:
[client]
port = 3306
socket = /tmp/mysql.sock改成:
socket=/var/run/mysqld/mysqld.sock
[mysqld]
port = 3306
datadir=/var/lib/mysql
socket=/tmp/mysql.sock改成:
socket=/var/run/mysqld/mysqld.sock
user=root
old_passwords=1
skip-locking
key_buffer_size = 16M
max_allowed_packet = 1M
table_open_cache = 64
sort_buffer_size = 512K
net_buffer_length = 8K
read_buffer_size = 256K
read_rnd_buffer_size = 512K
myisam_sort_buffer_size = 8M
log-bin=mysql-bin
binlog_format=mixed
server-id = 1
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
[mysqldump]
quick
max_allowed_packet = 16M
[mysql]
no-auto-rehash
[myisamchk]
key_buffer_size = 20M
sort_buffer_size = 20M
read_buffer = 2M
write_buffer = 2M
[mysqlhotcopy]
interactive-timeout
安装mysql数据
#mkdir -p /var/run/mysqld/
#mkdir -p /var/log/
#touch /var/run/mysqld/mysqld.pid
#mysql_install_db –user=root –force –basedir=/usr/local/mysql –datadir=/var/lib/mysql
尝试启动mysql应用程序
#mysqld_safe –socket=/tmp/mysql.sock &
如果没报错说明已经启动起来了。
到源码中拷贝启动文件support-files/mysql.server到目标板/etc/init.d/mysqld
修改文件内容:
basedir=/usr/local/mysql
datadir=/var/lib/mysql
pid_file=/var/run/mysqld/mysqld.pid
server_pid_file=/var/run/mysqld/mysqld.pid
修改完了保存文件重启目标板
#reboot
重启完后试着启动mysql数据库,在根目标执行
#/etc/init.d/mysqld start
5、设置mysql远程访问
# mysql -u root
mysql>use mysql
mysql> GRANT ALL PRIVILEGES ON
. TO ‘root’@’%’ IDENTIFIED BY ” WITH GRANT OPTION;
mysql> quit
end
错误:
root@am335x:/etc/init.d# ./mysqld start
Starting MySQL.. ERROR! Manager of pid-file quit without updating file.
root@am335x:/etc/init.d# mysql -u root
ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/tmp/mysql.sock’ (111)
解决:前面/var/run/mysqld没有创建