Databases
On this page
Manage MySQL and PostgreSQL databases and users separately. A single user can be granted Full or Read-only access to one, several, or all databases.
Create a database
Before starting, install MySQL or PostgreSQL from the server's Services tab. Each engine comes with a built-in crab user that has full access to every database from the server itself (view its password under Users).
- Open the server's Databases tab and choose New database.
- Pick the engine and enter a name (start with a lowercase letter; up to 32 lowercase letters, digits, or underscores).
- Keep Create a user with full access checked to create a dedicated app user automatically, or uncheck it to grant access to an existing user later.
- Copy the generated password (or enter your own, 12–64 letters and digits) and create the database.
Apps on the same server connect to 127.0.0.1 on port 3306 (MySQL) or 5432 (PostgreSQL). Click the key icon on any user to view its password and ready-to-copy connection URLs again.
Manage users and permissions
- Choose New user to create a custom user, or click Add a read-only user on any database to quickly create
<database>_ro. - Use a user's menu to update its database grants (None, Read-only, or Full per database), change where it can connect from, rotate its password, or delete it.
- To allow another server to connect (for example, an app server talking to a dedicated database server), choose Connects from → An address → From another server. Crabsmith automatically uses the private IP when both servers share a private network.
On PostgreSQL, tables created by any full-access user belong to the database, so other full users can modify them and read-only users can read both existing and newly created tables.
Connect from your local machine
Option 1: SSH tunnel (recommended)
Keep the database port closed to the internet and tunnel over SSH using your own authorized login and key:
# MySQL (connect your client to 127.0.0.1:13306)
ssh -N -L 13306:127.0.0.1:3306 your-user@your-server
# PostgreSQL (connect your client to 127.0.0.1:15432)
ssh -N -L 15432:127.0.0.1:5432 your-user@your-serverOption 2: Direct TLS connection
For teammates without SSH access, edit the user's Connects from setting to An address (an office or VPN IPv4/CIDR) or Anywhere.
- Crabsmith automatically opens the database port in UFW for that source and requires TLS.
- On MySQL, five failed password attempts lock the user for 24 hours.
- Give external desktop users Read-only access unless they need to write.
- Setting all users back to This server removes the Crabsmith-managed UFW rule for that port again (provider firewalls and manually added rules are separate).
Backup and restore
For scheduled backups to S3-compatible storage, with restore and download in the dashboard, use Backups. For a one-off copy, run mysqldump or pg_dump from the server's Terminal or over SSH. Each command below is separate—keep an off-server copy of your dump before restoring, and double-check the target database name.
MySQL backup
mysqldump -u your_user -p your_db > ~/your_db-backup.sqlMySQL restore
mysql -u your_user -p target_db < ~/your_db-backup.sqlPostgreSQL backup
pg_dump -U your_user -h 127.0.0.1 your_db > ~/your_db-backup.sqlPostgreSQL restore
psql -U your_user -h 127.0.0.1 target_db < ~/your_db-backup.sqlWhen it fails
- Connection refused: check that the engine is running, your app uses
127.0.0.1(notlocalhostsocket if expecting TCP), and the port/credentials match. - External connection failed: verify your IP matches the user's Connects from rule and that your database client has TLS/SSL enabled.
- Cannot remove database engine: delete managed databases and non-
crabusers first. Removing the service package leaves its data directory intact.