Can not get mariadb working under OpenWrt

I have been tearing my hair out for days, trying to get maridb server and client working on a NanoPi-R5S under OpenWRT. I have several times gone back to a fresh install of OpenWRT, and doing nothing more than installing mariadb-server and mariadb-client. But, once I get that far, nothing seems to work. I am logged into OpenWRT as root, and nearly every time I try to do anything with mysql, it refuses to log me in BECAUSE I am root, saying "Access denied for user root@localhost (using pasword: NO).

I had ZERO problems doing this on a Raspberry Pi, but this thing is making me crazy! What is the trick to making it work? The mysqld daemon loads and runs. ONE time I was able to get into mysql using "mysql -u root", but once I quit I could not get back in.

Has anyone gotten this to work properly?

Some more background on what I'm doing. On the Raspberry Pi, here is what I did, logged in as regular user "pi":

sudo apt -y install mariadb-server
sudo apt -y install mariadb-client
sudo service mysqld stop
sudo mysqld --skip-grant-tables &
mysql --user=root < ~/mysql_root_config.sql
kill mysqld
sudo service mysqld start
mysql --user=root -p < ~/sql_user_config.sql

mysql_root_config.sql contains this:

UPDATE mysql.user SET Grant_priv='Y', Super_priv='Y' WHERE User='root' ;
FLUSH PRIVILEGES ;
GRANT ALL ON *.* TO 'root'@'localhost' ;
FLUSH PRIVILEGES ;

SHOW GRANTS FOR 'root'@'localhost' ;

Quit

mysql_user_config.sql contains this:

GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' IDENTIFIED BY PASSWORD '*418CF519725AAA1BFF555A40A7A6DE18C406B1F2' WITH GRANT OPTION ;
FLUSH PRIVILEGES ;

CREATE USER 'pi'@'localhost' IDENTIFIED BY 'Raspberry' ; 

UPDATE mysql.user SET Grant_priv='Y', Super_priv='Y' WHERE User='pi' ;
FLUSH PRIVILEGES ;
GRANT ALL ON *.* TO 'pi'@'localhost' ;
FLUSH PRIVILEGES ;

GRANT ALL PRIVILEGES ON *.* TO 'pi'@'localhost' IDENTIFIED BY PASSWORD '*418CF519725AAA1BFF555A40A7A6DE18C406B1F2' WITH GRANT OPTION ;

SHOW GRANTS FOR 'pi'@'localhost' ;

CREATE DATABASE qdtimerdata;

USE qdtimerdata

CREATE TABLE timerdata1 (
idx INT(10) NOT NULL AUTO_INCREMENT,
timer_range INT(1) NOT NULL,
timer_lane INT(1) NOT NULL,
match_num INT(11) NOT NULL,
timer_enabled BOOLEAN NOT NULL,
timer_val CHAR(5) NOT NULL,
timestamp TIMESTAMP NULL DEFAULT NOW() ON UPDATE NOW(),
PRIMARY KEY(idx)
) AUTO_INCREMENT=1;

Quit

On the Pi, this all works perfectly every time.

On OpenWRT, I use opkg instead of apt, but the sequence is basically the same. There are no errors during install. I have to manually edit the config file to set enabled='1' (dont have to do that on the Pi), which gets the daemon to run, sometimes, but nothing else works, and, eventually, the daemon starts refusing to load at all. I cannot do the "--skip-grant-tables", because it says mysqld can't be run by root. The root script fails because it says the grants can't be updated. I'', sure I'm just missing one imporant step, but I have no clue what it is, and have been unable to find any documentation that helps me understand how it is supposed to work.

Also, the first time I try to start the daemon after an install, I get all these errors:

2023-02-12  9:39:26 0 [Warning] Could not open mysql.plugin table: "Table 'mysql.plugin' doesn't exist". Some options may be missing from the help text
2023-02-12  9:39:27 0 [Warning] Could not open mysql.plugin table: "Table 'mysql.plugin' doesn't exist". Some options may be missing from the help text
2023-02-12  9:39:27 0 [Warning] Could not open mysql.plugin table: "Table 'mysql.plugin' doesn't exist". Some options may be missing from the help text
2023-02-12  9:39:27 0 [Warning] Could not open mysql.plugin table: "Table 'mysql.plugin' doesn't exist". Some options may be missing from the help text
2023-02-12  9:39:27 0 [Warning] Could not open mysql.plugin table: "Table 'mysql.plugin' doesn't exist". Some options may be missing from the help text
Could not find plugin directory.
Will continue with "/usr/lib/mariadb/plugin".

See if anything in your knowledge base lines up with the open/closed Git log.

Not sure if this is progress or not... I can run mysql if I do "mysql -u root -p". Without the -p, it give me:

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

Once I login using a password, it lets me in, I can then do:

SET PASSWORD FOR 'root'@'localhost' = PASSWORD("");

If I quit, I can re-enter mysql without using the password.

Now, this is strange... I do opkg remove on both server and client, and then opk install on both, and it again REQUIRES the password. But it REQUIRES the password. But where is it GETTING the password from, since a fresh install should NOT have a root password. And the password it has is "Raspberry", which is the one I eventually want to set on the user account.

It appears to me there are dregs of earlier installs hanging around after I uninstall the packages. How can I wipe all traces of previous installs from the system, and truly start fresh?

The password (hashed) is stored in the grant table, which is along with the regular data tables stored in the data directory. It will not be removed by removing the package.

I assume the "data directory" is /srv/mysql? Is there a way to remove the password by editing one of the files there? Or should I just uninstall, delete /srv/mysql, then re-install? Is there anything else I should delete to remove any other vesitges of previous installs?

I think I've made a tiny bit of progress. I uninstalled both client and server, removed the entire /srv/mysql directory, then re-installed. After install, the daemon was running, but the /srv/mysql directory did not re-appear. I stopped, then restarted, the daemon, using "service mysqld stop/start", and /srv/mysqld re-appeared. I could then start mysql with either "mysql" or "mysql -u root". So, I tried to do the same configuration I did on the RPi system, starting with running the daemon in "skip-grant-tables". I stopped the daemon, and re-started it manually with "mysqld -u root --skip-grant-tables &", and it worked, with no errors. Next step was running the "root" script given above with the command line: "mysql -u root < ~/mysql_root_config.sql". This resulted in the following error:

ERROR 1348 (HY000) at line 1: Column 'Grant_priv' is not updatable

I've been here before, but at least this time mysql is running properly, and it is not demanding a root password. But what do I do to get past this? I only barely know what I'm doign with mysql, so this is all still quite mysterious to me...