Interactive Testing
We can run a Forgejo instance locally for testing:
TAGS='sqlite sqlite_unlock_notify' make watch
This will initiate a Forgejo instance locally, but it won’t give you the database to store any information. The database setup & initialization must be done manually. In my case, it’s my first time interacting with databases on my own, so I will just note down everything for future reference.
Install & Setup mysql
Database
Install mysql-server
:
sudo dnf install mysql-server
Check if it’s enabled & running:
sudo systemctl status mysqld
If mysqld
is inactive:
sudo systemctl enable mysqld
sudo systemctl start mysqld
Run the secure installation:
sudo mysql_secure_installation
Initialize mysqld
sudo mysql -u root -p
-u
username-p
password
Create the Database and user for Forgejo
- Create a Database
CREATE DATABASE forgejo CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
- Creates a new database named
forgejo
. CHARACTER SET utf8mb4
: Ensures full Unicode support, including emojis and multilingual characters.COLLATE utf8mb4_general_ci
: Sets the default text sorting and comparison rules (case-insensitive).
- Create a User
CREATE USER 'forgejouser'@'localhost' IDENTIFIED BY 'strongpass';
- Creates a new database user named
forgejouser
. 'localhost'
means the user can only connect from the local machine.IDENTIFIED BY 'strongpass'
: Sets the password for the user.
- Grant Privileges
GRANT ALL PRIVILEGES ON forgejo.* TO 'forgejouser'@'localhost';
- Gives the user full access (read/write/create/delete) to all tables in the
forgejo
database. - Does not affect other databases — it’s scoped to just
forgejo
.
- Reload Privileges
FLUSH PRIVILEGES;
- Forces the database to reload the privileges table so the changes take immediate effect.
Initial Database Configuration in Forgejo
Ensure that your database is properly configured using MySQL
(or any compatible local database you have set up).
Database Settings
Setting | Value |
---|---|
Database Type | MySQL |
Host | localhost |
Username | forgejouser |
Password | strongpass |
Database Name | forgejo |
Note: These values may vary depending on your specific database configuration.