Skip to main content
Most apps need a database. This guide covers installing and securing MySQL and PostgreSQL, the two most common options, on your Opus Host VPS.

Install MySQL

Secure the installation

Answer Y to remove anonymous users, disallow remote root login, remove the test database, and reload privileges.

Create a database and user

Connect from the command line

Allow remote connections (optional)

By default both databases only accept connections from localhost, which is the safest setup. If your app runs on the same VPS, leave it that way. If you truly need remote access:
  1. Bind the database to 0.0.0.0 in its config (/etc/mysql/mysql.conf.d/mysqld.cnf or /etc/postgresql/*/main/postgresql.conf).
  2. Update the client authentication file (pg_hba.conf for PostgreSQL).
  3. Open the port in your firewall. See Firewall.
  4. Restart the service.
Never expose a database to the public internet without a strong password, a firewall rule limiting source IPs, and TLS. Databases are constantly scanned and brute-forced.

Back up a database

Automate this with a cron job.