MySQL or MariaDB

Hello!

Has anyone setup either MySQL or MariaDB on a Toradex Embedded Linux device? I am looking for a how-to or tutorial on how to do so.

Right now, I have tried adding the following lines to local.conf before bitbaking. This did not work when I tried to run mysql -help. I got an error that the command was not found.

IMAGE_INSTALL_APPEND = " mysql5"
IMAGE_INSTALL_APPEND = " mariadb"
ACCEPT_FSL_EULA = "1"

I have been referencing the following community questions:

Any information would be greatly appreciated! Thank you so much!

You must include meta-oe to install mariadb, using IMAGE_INSTALL_append = "mariadb" with _append.

HI @samantha

Thanks for writing to the Toradex Support.

Which Embedded branch did you use to build your image?
Could you share you local.conf file?

Best regards,
Jaski

Hello @jaski.tx,

I have attached my local.conf file. The image successfully builds with the database ready to go. Unfortunately, it cannot build the Linux SDK. In order to cross compile for the database, I believe I need the header files generated by the SDK. Is this true and can you help me to successfully build it?

Here is my local.conf

And here are the errors from running bitbake console-tdx-image -c populate_sdk

ERROR: console-tdx-image-3.0b4-r0 do_populate_sdk: Unable to install packages. Command '/home/admin1/bin/build/tmp/work/apalis_imx6-tdx-linux-gnueabi/console-tdx-image/3.0b4-r0/recipe-sysroot-native/usr/bin/opkg --volatile-cache -f /home/admin1/bin/build/tmp/work/apalis_imx6-tdx-linux-gnueabi/console-tdx-image/3.0b4-r0/opkg.conf -t /home/admin1/bin/build/tmp/work/apalis_imx6-tdx-linux-gnueabi/console-tdx-image/3.0b4-r0/temp/ipktemp/ -o /home/admin1/bin/build/tmp/work/apalis_imx6-tdx-linux-gnueabi/console-tdx-image/3.0b4-r0/sdk/image/opt/tdx-x11/2.6.4/sysroots/armv7at2hf-neon-tdx-linux-gnueabi  --force_postinstall --prefer-arch-to-version   install alsa-utils alsa-utils-amixer alsa-utils-aplay aspell avahi-autoipd backports bmode-usb bzip2 can-utils connman connman-client connman-plugin-ethernet connman-plugin-loopback connman-plugin-wifi curl devmem2 dosfstools e2fsprogs e2fsprogs-mke2fs e2fsprogs-resize2fs e2fsprogs-tune2fs ethtool evtest file fs-init gdbserver gpio-export grep hdparm hostapd i2c-tools iperf3 iproute2 joe ldd libgpiod-tools libsoc2 libusbgx-examples libusbgx2 linux-firmware-ath10k linux-firmware-ath9k linux-firmware-iwlwifi linux-firmware-ralink linux-firmware-rtl8188eu linux-firmware-rtl8192cu linux-firmware-sd8686 linux-firmware-sd8688 linux-firmware-sd8787 linux-firmware-sd8797 linux-firmware-sd8887 linux-firmware-sd8997 linuxptp lmbench lsof mariadb memtester mimetypes minicom mmc-utils-cos mtd-utils mysql5 nbench-byte nfs-utils-client opkg packagegroup-base-extended packagegroup-basic packagegroup-boot packagegroup-core-boot packagegroup-core-standalone-sdk-target packagegroup-core-x11 packagegroup-dotnet-deps pciutils perf ppp procps ptpd rng-tools rt-tests run-postinsts sqlite3 strace stress target-sdk-provides-dummy tdx-oak-sensors timestamp-service tinymembench u-boot-fw-utils udev-extra-rules udev-toradex-rules util-linux util-linux-fstrim util-linux-lsblk wireless-regdb-static x-window-xterm' returned 1:
Collected errors:
 * Solver encountered 1 problem(s):
 * Problem 1/1:
 *   - package libdbi-perl-1.641-r0.armv7at2hf-neon requires perl-module-dynaloader, but none of the providers can be installed
 * 
 * Solution 1:
 *   - do not ask to install a package providing target-sdk-provides-dummy

 * Solution 2:
 *   - do not ask to install a package providing mariadb

 *   - do not ask to install a package providing mysql5

Thank you,

Samantha

Thank you so much @cleitonbueno! I was able to build the image and install it to my iMX6! Now onto cross-compiling!

hi @samantha

Could you share a sample code you want to cross-compile?

Thanks and best regards,
Jaski

Hey @jaski.tx!

After building the MySQL and MariaDB image, I wanted to write a C program to query the database. Here is a basic example:

#include <my_global.h>
#include <mysql.h>

int main(int argc, char **argv)
{
	MYSQL *con;
	MYSQL_RES *res;
	MYSQL_ROW row;
  char *server = ""; // secret
	char *user = ""; // secret
	char *password = "";  // secret
	char *database = ""; // secret

	con = mysql_init(NULL);

	/* Connect to database */
	if (!mysql_real_connect(con, server, user, password,
                                      database, 0, NULL, 0)) {
		fprintf(stderr, "%s\n", mysql_error(con));
		exit(1);
	}
  mysql_close(con);
}

Here is the command I run to cross compile: ${CC} -o testing testing.c -Wall mysql_config --libs -I/usr/include/mariadb -I/usr/include/mariadb/mysql

And here is the error I receive:

cc1: warning: include location "/usr/include/mariadb" is unsafe for cross-compilation [-Wpoison-system-directories]
cc1: warning: include location "/usr/include/mariadb/mysql" is unsafe for cross-compilation [-Wpoison-system-directories]
testing.c: In function ‘main’:
testing.c:185:12: warning: unused variable ‘row’ [-Wunused-variable]
  MYSQL_ROW row;
            ^~~
testing.c:184:13: warning: unused variable ‘res’ [-Wunused-variable]
  MYSQL_RES *res;
             ^~~
/usr/local/oecore-x86_64/sysroots/x86_64-angstromsdk-linux/usr/libexec/arm-angstrom-linux-gnueabi/gcc/arm-angstrom-linux-gnueabi/7.3.0/real-ld: warning: skipping incompatible /usr/lib/x86_64-linux-gnu/libmysqlclient.so while searching for mysqlclient
/usr/local/oecore-x86_64/sysroots/x86_64-angstromsdk-linux/usr/libexec/arm-angstrom-linux-gnueabi/gcc/arm-angstrom-linux-gnueabi/7.3.0/real-ld: error: cannot find -lmysqlclient
/usr/local/oecore-x86_64/sysroots/x86_64-angstromsdk-linux/usr/libexec/arm-angstrom-linux-gnueabi/gcc/arm-angstrom-linux-gnueabi/7.3.0/real-ld: warning: skipping incompatible /usr/lib/x86_64-linux-gnu/libpthread.so while searching for pthread
/usr/local/oecore-x86_64/sysroots/x86_64-angstromsdk-linux/usr/libexec/arm-angstrom-linux-gnueabi/gcc/arm-angstrom-linux-gnueabi/7.3.0/real-ld: warning: skipping incompatible /usr/lib/x86_64-linux-gnu/libz.so while searching for z
/usr/local/oecore-x86_64/sysroots/x86_64-angstromsdk-linux/usr/libexec/arm-angstrom-linux-gnueabi/gcc/arm-angstrom-linux-gnueabi/7.3.0/real-ld: warning: skipping incompatible /usr/lib/x86_64-linux-gnu/librt.so while searching for rt
/usr/local/oecore-x86_64/sysroots/x86_64-angstromsdk-linux/usr/libexec/arm-angstrom-linux-gnueabi/gcc/arm-angstrom-linux-gnueabi/7.3.0/real-ld: warning: skipping incompatible /usr/lib/x86_64-linux-gnu/libssl.so while searching for ssl
/usr/local/oecore-x86_64/sysroots/x86_64-angstromsdk-linux/usr/libexec/arm-angstrom-linux-gnueabi/gcc/arm-angstrom-linux-gnueabi/7.3.0/real-ld: warning: skipping incompatible /usr/lib/x86_64-linux-gnu/libcrypto.so while searching for crypto
/usr/local/oecore-x86_64/sysroots/x86_64-angstromsdk-linux/usr/libexec/arm-angstrom-linux-gnueabi/gcc/arm-angstrom-linux-gnueabi/7.3.0/real-ld: warning: skipping incompatible /usr/lib/x86_64-linux-gnu/libdl.so while searching for dl
/usr/local/oecore-x86_64/sysroots/x86_64-angstromsdk-linux/usr/libexec/arm-angstrom-linux-gnueabi/gcc/arm-angstrom-linux-gnueabi/7.3.0/real-ld: warning: skipping incompatible /usr/lib/x86_64-linux-gnu/libm.so while searching for m
/usr/local/oecore-x86_64/sysroots/x86_64-angstromsdk-linux/usr/libexec/arm-angstrom-linux-gnueabi/gcc/arm-angstrom-linux-gnueabi/7.3.0/real-ld: warning: skipping incompatible /usr/lib/x86_64-linux-gnu/libc.so while searching for c
/tmp/cc225HBa.o:testing.c:function main: error: undefined reference to 'mysql_init'
/tmp/cc225HBa.o:testing.c:function main: error: undefined reference to 'mysql_real_connect'
/tmp/cc225HBa.o:testing.c:function main: error: undefined reference to 'mysql_error'
/tmp/cc225HBa.o:testing.c:function main: error: undefined reference to 'mysql_close'

Any updates @jaski.tx?

HI @samantha

Sorry for the delayed answer. Are you still facing the issue?

Best regards,
Jaski

Hello @jaski.tx!

I used @cleitonbueno’s comment to solve this issue.

Thanks for checking in!

Perfect. Thanks for the feedback.