Openwrt 21 , maria-db mysqld wont start

I have openwrt 21 with mysql server provided by maria-db package.

when I run the command /etc/init.d/mysqld restart I get the following erro in result

root: [ERROR] can not detect privileges table, you might need to
root: run 'mysql_install_db --force' to initialize the system tables

when I run mysql_install_db --force then it says

Could not find plugin directory.
Will continue with "/usr/lib/mariadb/plugin".
mysql.user table already exists!
Run mysql_upgrade, not mysql_install_db

and mysql_upgrade will print this error

root@Router:~# mysql_upgrade
Version check failed. Got the following error when calling the 'mysql' command line client
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld.sock' (111)
FATAL ERROR: Upgrade failed

On the other hand If I run mysqld
The mysql server starts

My goal is to start the mysql-server on boot. What am I missing ?

I just installed it, works fine - x86_64 21.02.2

root@OpenWrt:/etc/init.d# ./mysqld start
2022-03-16 16:35:01 0 [Warning] Could not open mysql.plugin table. Some options may be missing from the help text
2022-03-16 16:35:01 0 [Warning] Could not open mysql.plugin table. Some options may be missing from the help text
2022-03-16 16:35:01 0 [Warning] Could not open mysql.plugin table. Some options may be missing from the help text
2022-03-16 16:35:01 0 [Warning] Could not open mysql.plugin table. Some options may be missing from the help text
2022-03-16 16:35:02 0 [Warning] Could not open mysql.plugin table. Some options may be missing from the help text
Could not find plugin directory.
Will continue with "/usr/lib/mariadb/plugin".
Installing MariaDB/MySQL system tables in '/srv/mysql/' ...
OK

To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system


Two all-privilege accounts were created.
One is root@localhost, it has no password, but you need to
be system 'root' user to connect. Use, for example, sudo mysql
The second is root@localhost, it has no password either, but
you need to be the system 'root' user to connect.
After connecting you can set the password, if you would need to be
able to connect as any of these users with a password and without sudo

See the MariaDB Knowledgebase at http://mariadb.com/kb or the
MySQL manual for more instructions.

You can start the MariaDB daemon with:
cd '/usr/' ; /usr//bin/mysqld_safe --datadir='/srv/mysql/'

You can test the MariaDB daemon with mysql-test-run.pl
cd '/usr//mysql-test' ; perl mysql-test-run.pl

Please report any problems at http://mariadb.org/jira

The latest information about MariaDB is available at http://mariadb.org/.
You can find additional information about the MySQL part at:
http://dev.mysql.com
Consider joining MariaDB's strong and vibrant community:
https://mariadb.org/get-involved/

root@OpenWrt:/etc/init.d# ps |grep maria
 4351 mariadb   337m S    /usr/bin/mysqld
 4423 root      1096 S    grep maria
root@OpenWrt:/etc/init.d#

I tried to remove my modifications of my.cnf and it now starts . The problem now I face is that after every reboot my databases will be deleted . What can be the cause of that

you write it to memory not flash storage, don't write it to flash, it'll kill it, if it's a regular router you're using.

Its an olimex board with the OS on sd card. If written to memory then it means that the data will be lost on reboot, isnt that the case?

Yes, I thought that's what I said :wink:

If the defaults are the same for your device as for regular routers, then the DB is created
on RAM FS, to avoid flash wear, and lost during reboot.

The path should be changeable though.

I have set the data dir to /usr/lib/mysql/ that should be persistant over reboots

@frollic can you please let me know how to configure maria-db to store its db on disk?

tried /etc/mysql/conf.d/50-server.cnf ?

or softlink the default location, which appears to be /srv/mysql/.