Dietpi installer can not create mariaDB databases when needed

  • DietPi version | 8.13.2
  • Distro version | bullseye
  • Kernel version | Linux RPi4 5.15.84-v8+ #1613 SMP PREEMPT Thu Jan 5 12:03:08 GMT 2023 aarch64 GNU/Linux
  • SBC model | RPi 4

Additional Information (if applicable)

  • Software title | phpmyadmin, wordpress, anything which needs mariadb/mysql
  • Was the software title installed freshly or updated/migrated? → fresh
  • Can this issue be replicated on a fresh installation of DietPi? No, it worked on my RPi 3, which is relatively fresh

I tried to install phpmyadmin and wordpress and the installation completed, but throwed an error:

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
[FAILED] Creating MariaDB database phpmyadmin for user phpmyadmin | Exited with error

Also a similiar message appears when trying to install wordpress.
I had to manually create the databases to make wordpress work.
I also made sure that my mariaDB root user password is the same as my current global software password. (which the installer will use?)
But it seems like the installer did not try to use a password at all? (using password: NO)

hmm I did a test on my R5S and install completed without issues.

WordPress

[ INFO ] DietPi-Create_MySQL_DB | Creating MariaDB database wordpress for user wordpress
[  OK  ] DietPi-Create_MySQL_DB | systemctl start mariadb
[  OK  ] Creating MariaDB database wordpress for user wordpress | Completed

phpMyAdmin

[ INFO ] DietPi-Create_MySQL_DB | Creating MariaDB database phpmyadmin for user phpmyadmin
[  OK  ] DietPi-Create_MySQL_DB | systemctl start mariadb
[  OK  ] Creating MariaDB database phpmyadmin for user phpmyadmin | Completed

Both database are available right after installation

root@DietPiR5S:~# mysql -e "SHOW DATABASES;"
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| phpmyadmin         |
| wordpress          |
+--------------------+
root@DietPiR5S:~#

Yes usually root user don’t require a password to login into MariaDB.

So the problem is that I set a password for root someday?
Isn’t it somewhat unsafe that root mariaDB user has no password set?

well, this is possible from the local system itself only. Means you would need to be on the system already to be able to execute commands. On a default setup MariaDB is not excepting connections from the network :wink:

Means, someone would need to be on your system already to be able to execute commands as root user.

Hello @Joulinar
I have the same issue while installing Forgejo.
Do you suggest to revert to the situation where there was no password for the root user ?
If so, how to do this ?

Regards
Valentin

did you actively set a root password for the database user?

Yes I did.

In the meantime I found out it is possible to revert to the no password policy by setting the authentication method of the root@localhost user to unix_socket in mariadb.

But beforehand I’d like to make sure that this is the method you recommend.

BR
Valentin

I don’t think this is correct way. Better to set an empty password

ALTER USER 'root'@'localhost' IDENTIFIED BY '';