Skip to content

Commit b725c4e

Browse files
bagasmelafriks
andauthored
Add a step for binding IP address for listening on remote database (#12898)
* Add listen address configuration step * Fix numbering order Signed-off-by: Bagas Sanjaya <bagasdotme@gmail.com> Co-authored-by: Lauris BH <lauris@nix.lv>
1 parent 95ff559 commit b725c4e

File tree

1 file changed

+23
-12
lines changed

1 file changed

+23
-12
lines changed

docs/content/doc/installation/database-preparation.en-us.md

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,20 @@ Note: All steps below requires that the database engine of your choice is instal
2121

2222
## MySQL
2323

24-
1. On database instance, login to database console as root:
24+
1. For remote database setup, you will need to make MySQL listen to your IP address. Edit `bind-address` option on `/etc/mysql/my.cnf` on database instance to:
25+
26+
```ini
27+
bind-address = 203.0.113.3
28+
```
29+
2. On database instance, login to database console as root:
2530

2631
```
2732
mysql -u root -p
2833
```
2934

3035
Enter the password as prompted.
3136

32-
2. Create database user which will be used by Gitea, authenticated by password. This example uses `'gitea'` as password. Please use a secure password for your instance.
37+
3. Create database user which will be used by Gitea, authenticated by password. This example uses `'gitea'` as password. Please use a secure password for your instance.
3338

3439
For local database:
3540

@@ -49,15 +54,15 @@ Note: All steps below requires that the database engine of your choice is instal
4954

5055
Replace username and password above as appropriate.
5156

52-
3. Create database with UTF-8 charset and collation. Make sure to use `utf8mb4` charset instead of `utf8` as the former supports all Unicode characters (including emojis) beyond *Basic Multilingual Plane*. Also, collation chosen depending on your expected content. When in doubt, use either `unicode_ci` or `general_ci`.
57+
4. Create database with UTF-8 charset and collation. Make sure to use `utf8mb4` charset instead of `utf8` as the former supports all Unicode characters (including emojis) beyond *Basic Multilingual Plane*. Also, collation chosen depending on your expected content. When in doubt, use either `unicode_ci` or `general_ci`.
5358

5459
```sql
5560
CREATE DATABASE giteadb CHARACTER SET 'utf8mb4' COLLATE 'utf8mb4_unicode_ci';
5661
```
5762

5863
Replace database name as appropriate.
5964

60-
4. Grant all privileges on the database to database user created above.
65+
5. Grant all privileges on the database to database user created above.
6166

6267
For local database:
6368

@@ -73,9 +78,9 @@ Note: All steps below requires that the database engine of your choice is instal
7378
FLUSH PRIVILEGES;
7479
```
7580

76-
5. Quit from database console by `exit`.
81+
6. Quit from database console by `exit`.
7782

78-
6. On your Gitea server, test connection to the database:
83+
7. On your Gitea server, test connection to the database:
7984

8085
```
8186
mysql -u gitea -h 203.0.113.3 -p giteadb
@@ -87,37 +92,43 @@ Note: All steps below requires that the database engine of your choice is instal
8792

8893
## PostgreSQL
8994

90-
1. PostgreSQL uses `md5` challenge-response encryption scheme for password authentication by default. Nowadays this scheme is not considered secure anymore. Use SCRAM-SHA-256 scheme instead by editing the `postgresql.conf` configuration file on the database server to:
95+
1. For remote database setup, configure PostgreSQL on database instance to listen to your IP address by editing `listen_addresses` on `postgresql.conf` to:
96+
97+
```ini
98+
listen_addresses = 'localhost, 203.0.113.3'
99+
```
100+
101+
2. PostgreSQL uses `md5` challenge-response encryption scheme for password authentication by default. Nowadays this scheme is not considered secure anymore. Use SCRAM-SHA-256 scheme instead by editing the `postgresql.conf` configuration file on the database server to:
91102

92103
```ini
93104
password_encryption = scram-sha-256
94105
```
95106

96107
Restart PostgreSQL to apply the setting.
97108

98-
2. On the database server, login to the database console as superuser:
109+
3. On the database server, login to the database console as superuser:
99110

100111
```
101112
su -c "psql" - postgres
102113
```
103114

104-
3. Create database user (role in PostgreSQL terms) with login privilege and password. Please use a secure, strong password instead of `'gitea'` below:
115+
4. Create database user (role in PostgreSQL terms) with login privilege and password. Please use a secure, strong password instead of `'gitea'` below:
105116

106117
```sql
107118
CREATE ROLE gitea WITH LOGIN PASSWORD 'gitea';
108119
```
109120

110121
Replace username and password as appropriate.
111122

112-
4. Create database with UTF-8 charset and owned by the database user created earlier. Any `libc` collations can be specified with `LC_COLLATE` and `LC_CTYPE` parameter, depending on expected content:
123+
5. Create database with UTF-8 charset and owned by the database user created earlier. Any `libc` collations can be specified with `LC_COLLATE` and `LC_CTYPE` parameter, depending on expected content:
113124

114125
```sql
115126
CREATE DATABASE giteadb WITH OWNER gitea TEMPLATE template0 ENCODING UTF8 LC_COLLATE 'en_US.UTF-8' LC_CTYPE 'en_US.UTF-8';
116127
```
117128

118129
Replace database name as appropriate.
119130

120-
5. Allow the database user to access the database created above by adding the following authentication rule to `pg_hba.conf`.
131+
6. Allow the database user to access the database created above by adding the following authentication rule to `pg_hba.conf`.
121132

122133
For local database:
123134

@@ -137,7 +148,7 @@ Note: All steps below requires that the database engine of your choice is instal
137148

138149
Restart PostgreSQL to apply new authentication rules.
139150

140-
6. On your Gitea server, test connection to the database.
151+
7. On your Gitea server, test connection to the database.
141152

142153
For local database:
143154

0 commit comments

Comments
 (0)