GlobalForms stores its own data in MongoDB. It can also connect to SQL databases so forms can read from and write to your business systems. This page covers both connections.
Which database is used for what
|
Database |
Used for |
Configured in |
|---|---|---|
|
MongoDB |
GlobalForms data: forms, submissions, users and roles. Required. |
|
|
Microsoft SQL Server |
SQL Query form actions and SQL data lookups (Resquel) |
|
|
MySQL / MariaDB |
SQL Query form actions and SQL data lookups (Resquel) |
|
|
PostgreSQL |
SQL Query form actions and SQL data lookups (Resquel) |
|
All of these settings go in config\local.json. Restart the GlobalForms service after any change. See Configuration Files.
MongoDB
GlobalForms normally uses the MongoDB server that GlobalCapture installs, with its own database on that server. A standalone MongoDB server is only for upgrades where GlobalCapture can't be updated yet; see System Requirements.
Setup writes the MongoDB connection to local.json from the values you enter during installation. To change it later, for example after moving MongoDB to another server, edit the mongo setting.
{
"mongo": "mongodb://db-server:27017/GlobalForms"
}
The value is a standard MongoDB connection string:
mongodb://[username:password@]host[:port]/database[?options]
|
Situation |
Example |
|---|---|
|
No authentication |
|
|
With a database user |
|
|
With TLS encryption |
|
-
authSource is the database that holds the MongoDB user, usually
admin. -
If the password contains special characters such as
@,:or/, URL-encode them (for example@becomes%40). -
Use a dedicated MongoDB user for GlobalForms with access only to its database.
Standalone MongoDB: create a database user
If you run GlobalForms on a standalone MongoDB server that you manage, turn on MongoDB authentication and create a user that can read and write only the GlobalForms database. Connect with mongosh as a MongoDB administrator and run:
use admin
db.createUser({
user: "svc_globalforms",
pwd: passwordPrompt(),
roles: [ { role: "readWrite", db: "GlobalForms" } ]
})
Enter the password when prompted. Then use this user and password during GlobalForms setup, with authSource set to admin. If your GlobalForms database has a different name, use that name in db.
Do not change mongoSecret. Setup generates this key to protect sensitive values stored in MongoDB. Keep it private and keep a secure copy of local.json. If you move GlobalForms to a new server, copy the same mongoSecret.
If GlobalCapture uses the same MongoDB server, update GlobalCapture before GlobalForms whenever you upgrade.
SQL connections for SQL Query actions
The SQL Query form action runs a SQL statement when a form is submitted, for example to save data or generate an ID. It uses the connections in settings.databases, one per database type: mssql, mysql or postgresql.
{
"settings": {
"databases": {
"mssql": {
"host": "sql-server",
"port": "1433",
"database": "FormsData",
"user": "svc_globalforms",
"password": "<password>"
},
"postgresql": {
"host": "pg-server",
"port": "5432",
"database": "forms_data",
"user": "svc_globalforms",
"password": "<password>"
}
}
}
}
|
Setting |
Description |
|---|---|
|
|
Server name or IP address. |
|
|
1433 (SQL Server), 3306 (MySQL), 5432 (PostgreSQL) |
|
|
Default database. A query can also name another database the user can access. |
|
|
The database login |
All five settings are required for a database type to appear in the SQL Query action. For SQL Server, TCP/IP connections must be enabled and SQL Server authentication allowed. See SQL Query Form Actions.
SQL connections for data lookups (Resquel)
To let forms read data from SQL, for example to fill a Select list from a table, you define queries as GlobalForms routes in settings.resquel. Resquel supports SQL Server, MySQL, MariaDB and PostgreSQL. See Setting Up SQL Lookups (Resquel).
Security recommendations
-
Create a dedicated database account for GlobalForms. Do not use
sa,rootor other administrator accounts. -
Grant only the permissions your forms need, such as read-only access for lookups.
-
Use encrypted connections where your database supports them.
-
Limit who can read
config\local.json, because it contains database passwords.
Troubleshooting
|
Symptom |
Cause and fix |
|---|---|
|
The service stops after changing |
GlobalForms cannot reach MongoDB. Check the host, port, user, password and |
|
Authentication failed for MongoDB |
Check |
|
A database type is missing from the SQL Query action |
One of its five settings is empty. Complete them and restart the service. |
|
|
The |
|
A SQL Query action fails |
Test the same login and query in your database tool. Check that the database accepts network connections and that the firewall allows the port. |
|
Login failed for a SQL Server user |
SQL Server may be set to Windows authentication only. Enable SQL Server and Windows Authentication mode. |