Access Denied for Forgejo's DB

Creating a bug report/issue

I have searched the existing open and closed issues

Required Information

  • DietPi version | G_DIETPI_VERSION_CORE=10
    G_DIETPI_VERSION_SUB=6
    G_DIETPI_VERSION_RC=2
    G_GITBRANCH=‘master’
    G_GITOWNER=‘MichaIng’
  • Distro version | trixie
  • Kernel version | Linux DietPi 6.12.107+deb13-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.12.107-1 (2026-08-29) x86_64 GNU/Linux
  • Architecture | amd64
  • SBC model | Native PC (x86_64)
  • Power supply used | (EG: 5V 1A RAVpower)
  • SD card used | (EG: SanDisk ultra)

Additional Information (if applicable)

  • Software title | Forgejo
  • the software title is installed freshly
  • Can this issue be replicated on a fresh installation of DietPi? Yes
    ← If you sent a “dietpi-bugreport”, please paste the ID here →
  • Bug report ID | echo $G_HW_UUID

Steps to reproduce

  1. Install Forgejo
  2. Go to the config page
  3. set everything up
  4. It will give access denied

Expected behaviour

  • My root or software installation password, the password ‘dietpi’ or no password should be working as the DB password

Actual behaviour

  • Access denied when I tried all the passwords I could think of

Extra details

The database settings are invalid: Error 1698 (28000): Access denied for user 'root'@'localhost'

OK looks like the root user in MariaDB is created like this:

MariaDB [(none)]> SHOW CREATE USER 'root'@'localhost';
+----------------------------------------------------------------------------------------------------+
| CREATE USER for root@localhost                                                                     |
+----------------------------------------------------------------------------------------------------+
| CREATE USER `root`@`localhost` IDENTIFIED VIA mysql_native_password USING 'invalid' OR unix_socket

So you can not use root to login, except via CLI.
@MichaIng we should update our docs, they say

  1. Username = root
  2. Password = The same as your root login password, default is dietpi

@AarafGaming to use root user you would need to set a password for it, but it’s even better to create an own user for Forgejo.

Or maybe you can even use SQLite, should be enough if you just run your personal Forgejo instance.
You can do this by installing SQLite via dietpi-software (and maybe uninstall MariaDB if you don’t need it), forgejo has it’s own path at /mnt/dietpi_userdata/forgejo where you can store the SQlite db.
In the Forgejo setup, just choose SQLite and as path /mnt/dietpi_userdata/forgejo/data/forgejo.db.

Two things are mixed up here:

  • MariaDB root access to manage (MariaDB) users and databases.
  • Forgejo’s own MariaDB database and account, which both is named “forgejo”.

You must never give any software root access to MariaDB, and luckily it is prevented by default with the UNIX user socket authentication module: No one but the UNIX root user can login as root to MariaDB.

Maybe our first run docs are ambiguous: Cloud and Backup Systems Software Options - DietPi.com Docs
It lists only those fields which need to be changed in the setup dialog. The database name and user fields should be prefilled with “forgejo”, which is correct.

Ok, but for what is then the mariadb root password, which is listed in the docs, when nobody can use it? Unix user root does not need it and any other user can not login as root anyways, and it’s also set as invalid:

CREATE USER `root`@`localhost` IDENTIFIED VIA mysql_native_password USING 'invalid' OR unix_socket

Anyways, @AarafGaming I tested it again, with MariaDB, and indeed it was working with my software password and the user forgejo (and the other settings mentioned in our docs)

maybe I overlooked it, but where is the root user password listed in the forgejo section. Maybe I overlooked it.

I’m talking about mariaDB.

Indeed, the MariaDB docs are wrong, I guess copy&pasted from the old phpBB docs, from ancient times when MySQL root access was still possible via password.

Nowadays: When calling the mariadb command as UNIX root user, it logs in as MariaDB root user automatically, without any password needed. But since there is not password, it is not possible to login with this account as any other UNIX user. This can/should never be used for anything else than creating new MariaDB users and databases for 3rd party software to use, like creating the forgejo user and database, for the Forgejo service. dietpi-software does this automatically, of course.

I just opened an issue to not forget fixing this: Fix MariaDB quick access docs · Issue #1222 · MichaIng/DietPi-Docs · GitHub