Reset db password ncp-docker

For completion, in case anyone else finds this thread off the back of searching “SQLSTATE[HY000] [1045] Access denied for user ‘ncadmin’@‘localhost’” my case was caused by different issue
(this is on a NextCloudPi Docker-compose install on RasPi B+)

Setting up Rainloop webmail contacts requires adding a database and due to an erroneous command entered by myself (messing with root account and ending up locked out!!) the fix to this appeared to have borked the ncadmin password in MariaDB so the solution was to reset the ncadmin password in mysql:

Log into the database monitor from (in my case) root prompt inside the Docker container ( docker exec -it nextcloudpi /bin/bash ):

mysql -uroot -p

(iirc the original install does not require the -p to prompt for password but I ended up setting one in my endeavours to set up a Rainloop database! Password is blank by default)

Then from the SQL prompt:

MariaDB [(none)]> SET PASSWORD FOR 'ncadmin'@'localhost' = PASSWORD ('default');
then
MariaDB [(none)]> flush privileges;
then to exit:
MariaDB [(none)]> exit;

(just type the commands to the right of the MariaDB [(none)]> part above.

I then restarted the NCP Docker container:
docker restart nextcloudpi

And all is well in the world again (plus I now had my Rainloop DB accessible to the system - YAY!)

[Edit] Spoke too soon! While manually changing password in the DB will enable NC to start, I’m currently finding that something is resetting this change on restart in either the DB config and/or the NCP config …/nextcloud/config/config.php and I’ve not yet found out why…I’ve also posted to this thread wither similar problem to mine: Dbpassword issues in config.php