1. Setup Mysql. Устанавливаем MySql
Firstly, we need mysql:
opkg update
opkg install mysql5
/etc/init.d/mysqld start
Oops, not started. Well, let's try to comment 3rd line in /etc/init.d/mysqld. (Открываем файл /etc/init.d/mysqld и комментируем строку №3 ).
root@beaglebone:~# /etc/init.d/mysqld start
root@beaglebone:~# 000101 12:32:31 mysqld_safe Logging to '/var/log/mysqld.err'.
000101 12:32:31 mysqld_safe Starting mysqld daemon with databases from /var/mysql
root@beaglebone:~# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.1.40 Source distribution
Now, we want to start MySql when board is booting. Create file (Remember, we have file explorer in eclipse )
and fill it:
[Unit]
Description=MySQL database server
After=syslog.target
After=network.target
[Service]
ExecStart=/usr/bin/mysqld_safe
ExecStop=/bin/kill -15 $MAINPID
PIDFile=/var/lib/mysql/mysql.pid
Restart=always
[Install]
WantedBy=multi-user.target
systemctl enable mysql.service
systemctl start mysql.service
systemctl status mysql.service
In my board -- FAIL :(
But when:
reboot
<..>
root
Last login: Sat Jan 1 11:05:30 EST 2000 on ttyGS0
root@beaglebone:~# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Enjoy:)
2. Setup MySql Client for c++
I don't know how we will do it. Let's try.
В текущий момент попробуем настроить mysql для использования из-под eclipse. Чтобы работало на BBB нужна библиотека на плате, скомпилированная под ARM. Попробуем начать с нее...
root@beaglebone:~# opkg install libmysqlclient-dev
Installing libmysqlclient-dev (5.1.40-r10.5) to root...
Downloading http://feeds.angstrom-distribution.org/feeds/v2012.12/ipk/eglibc/armv7a-vfp-neon/base/libmysqlclient-dev_5.1.40-r10.5_armv7a-vfp-neon.ipk.
Configuring libmysqlclient-dev.
root@beaglebone:~#
Then, copy *.h files to local machine. Add this path to preprocessor include path:
root@beaglebone:~# find / -name "mysql.h"
/usr/include/mysql/mysql.h
Подумал, что теперь может оказаться достаточным просто перекинуть библиотеку и файлы заголовков на локальную машину. Копируем папку /usr/include/mysql на локальную машину, не забыв прописать путь в эклипсе.
Now, file "mysql.h" was found, but
D:\src\bone\test001\bb_debug/..\src/HelloWorld.cpp:35: undefined reference to `mysql_get_client_info'
I think that is OK -- no path to library
Copy all mysqlclient to local machine
/usr/lib/libmysqlclient_r.so.16.0.0
/usr/lib/libmysqlclient.la
/usr/lib/libmysqlclient.so.16.0.0
/usr/lib/libmysqlclient_r.so.16
/usr/lib/libmysqlclient.so
/usr/lib/libmysqlclient.so.16
And write paths in eclipse g++ linker, and add library! mysqlclient.
When i compile, error message is changed:
arm-linux-gnueabi-g++ "-LD:\\LinaroGCC\\arm-linux-gnueabihf\\lib" "-LD:\\LinaroGCC\\mysql" -o test001 "src\\test.o" "src\\HelloWorld.o" "bbblib\\BBTCPClient.o" "bbblib\\BBLog.o" "bbblib\\BBLed.o" "bbblib\\BBDirectGPIO.o" -lmysqlclient
d:/linarogcc/bin/../lib/gcc/arm-linux-gnueabi/4.6.3/../../../../arm-linux-gnueabi/bin/ld.exe: warning: libz.so.1, needed by D:\LinaroGCC\mysql/libmysqlclient.so, not found (try using -rpath or -rpath-link)
D:\LinaroGCC\mysql/libmysqlclient.so: undefined reference to `compress'
D:\LinaroGCC\mysql/libmysqlclient.so: undefined reference to `uncompress'
collect2: ld returned 1 exit status
Ok, copy libz.* too. And all "z" library to libraries in g++ linker.
Compiled!
lib ver:<5.1.40>
Win! Enjoy!
|