Now we have a webserver for allowing incoming connections, and a mail server for sending out emails, we need a database for gitea to store information. For this we will use MariaDB.

sudo apt-get install mariadb-client mariadb-server
sudo mysql_secure_installation

This will install MariaDB, and then run a script to make the database more secure. Initially the root password is blank, so simply press enter when asked, you will then be asked if you want to set a root password, which we shall do. You should then set a secure password (I still recommend using a password manager to generate and store secure passwords for you) for the root user. Once you have set, and confirmed the new root password you should select yes for all the remaining options. The password you set is not actually used, as MariaDB sets the root user to authenticate using unix sockets, but if we dump all the databases and import into an older version, or MySQL, having this password set will still allow us to use the database should we need too. We will now need to create a database and user for git.

sudo mysql

This will get us to a database prompt as our database root user, where we need to issue the following commands.

CREATE DATABASE gitea;
CREATE USER 'gitea'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON gitea.* to 'gitea'@'localhost';
FLUSH PRIVILEGES;
quit

This creates a database called “gitea” and also a user called “gitea” (that does use the password we set, and you should use something other than “password”) which can only login locally, and grants it access to the gitea database.

We should now be set to actually install our git server.