2008年5月3日 星期六

Porting MySQL

同樣的事情對岸也有人做過了,照本宣科.
下載: mysql-5.0.51b.tar.gz

./configure --prefix=/home/showtime/mysql --build=i386-linux --host=arm-linux --with-charset=utf8 --without-debug --without-docs --without-man --without-bench --with-named-curses-libs=/home/showtime/mysql/ncurses-5.6/lib/libncurses.a遇到下列錯誤:
1) checking "return type of sprintf"... configure: error: cannot run test program while cross compiling
2) checking for atomic operations... configure: error: cannot run test program while cross compiling
3) checking for int8... configure: error: cannot run test program while cross compiling
4) checking for restartable system calls... configure: error: cannot run test program while cross compiling
5) checking if conversion of longlong to float works... configure: error: cannot run test program while cross compiling
6) error: Your compiler cannot convert a longlong value to a float!
在網路上搜尋發現這幾個似乎是常碰到的問題,表示此版本的mysql尚未支援corss-compile
看別人的解法是直接略過configure裡面的測試(不知道使用的時候會不crash?)
configure script裡在checking若遇到錯誤就會中斷
於是移除上方這些測試的離開語句{ (exit 1); exit 1; }; (請注意大括號的配對)

參數--with-named-curses-libs是因為錯誤訊息: checking for termcap functions library... configure: error: No curses/termcap library found
請自行下載ncurses,並cross-compile
./configure --host=arm-linux && make

mysql configure通過後, make && make install
將install的東西copy起來準備到target上測試

將lib放到正確的路徑,或使用link達成
開始安裝: ./mysql_install_db --user=root
出現錯誤:
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

執行hostname看看名字是什麼
新增/etc/hosts
127.0.0.1 localhost
127.0.0.1 你的hostname
再安裝一次,成功了.

啟動server: ./mysqld_safe --user=root & (有時後會失敗,但重開機後又正常?)
建立密碼: ./mysqladmin -u root password 'your password' (這一步應該可以省略了)
連接server: ./mysql -u root
成功連接上以後就會出現歡迎訊息
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.0.51b Source distribution

稍微測試一下:
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| test |
+--------------------+
3 rows in set (0.00 sec)
mysql> use mysql;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL ser
ver version for the right syntax to use near 'user mysql' at line 1
(不知道為什麼)
mysql> use test;
Database changed
跑一下mysql tutorial的sample
mysql> CREATE TABLE pet (name VARCHAR(20), owner VARCHAR(20),
-> species VARCHAR(20), sex CHAR(1), birth DATE, death DATE);
mysql> INSERT INTO pet VALUES ('Puffball','Diane','hamster','f','1999-03-30',NULL);
mysql> SELECT * FROM pet;
+----------+-------+---------+------+------------+-------+
| name | owner | species | sex | birth | death |
+----------+-------+---------+------+------------+-------+
| Puffball | Diane | hamster | f | 1999-03-30 | NULL |
+----------+-------+---------+------+------------+-------+
1 row in set (0.00 sec)

大致上都還蠻正常的;)

ref:
MySQL Typical configure Options
mysql數據庫在arm+linux平台上的移植

0 意見: