# Set up a separate database server and connect a site to it

Keep your sites' data on a server of its own, let only your website servers reach it, and connect a site without typing connection details.

A separate database server keeps your data apart from your websites: a busy site does not slow the database down, several website servers can share one database, and you can resize each server on its own. This guide takes about 15 minutes plus the time the new server takes to set up.

## What you need

- A website server in Fuzops with the site that will use the database. The site must be one whose settings Fuzops fills in, such as Laravel, Symfony, Node.js, Django or Bedrock.
- A way to create one more server: a connected cloud account, or a fresh server of your own.

## Steps

1. **Create the database server.** Choose **Add a server**, then the kind **Database server**, and pick the **Database software** your site was built for: MySQL, MariaDB or PostgreSQL. If your provider offers a private network, put the database server on the same private network as your website server: the two then talk over it instead of the internet. See [Create a server](https://internal.fuzops.com/docs/create-a-server).

2. **Wait until it is Online.** It is set up to accept connections from the network, offers encrypted connections, and signs every user in with a password. It starts **closed to everyone**.

3. **Allow your website server.** Open the database server, then **Databases & backups** › **Databases**. Under **Who can reach this database server**, find your website server in **Your website servers** and choose **Allow**. When it has a private network address and a public one, Fuzops suggests the private one if both servers share a private network.

   ![Who can reach this database server, with the team's website servers and their Allow buttons](https://internal.fuzops.com/docs-img/database-server-access.webp "Allow your website servers one click at a time.")

4. **Connect the site.** Open the **website** server's **Databases** page. Under **Use a database on another server**, choose **Use a database on another server…**, then the **Site** and the **Database server**, and choose **Create and connect**.

5. **Save the password.** The page shows the new user's password once, with the address and user name to use. Fuzops has already written them into the site's [Environment](https://internal.fuzops.com/docs/environment).

6. **Move your data, then publish.** If the site already has data in its old database, copy it over first (for example with a backup and restore). Then publish an update so the site starts using the new database. See [Publish an update and go back](https://internal.fuzops.com/docs/guides/publish-an-update-and-go-back).

## What you should see

- On the database server, **Who can reach this database server** lists your website server by name.
- The new user's quick look says "Can sign in from" your website server's address "· the server accepts connections from there".
- The site's **Environment** has the database server's address, the database name, the user name and the password.

To use the database from a server outside Fuzops, type its address under **Another address or range**, then add a database user with **One other server or address** and that same address.

## Back it up

Back the database up from the **database server's** **Backups** page: the backup runs on the database server itself. See [Backups and restore](https://internal.fuzops.com/docs/backups). The site's own backups keep its files.

## If it goes wrong

**The site cannot connect to the database.** Open the database user's quick look on the database server: it says which part keeps the connection out.

- "that address is not on Who can reach this database server": choose **Allow** for the website server, or type its address under **Another address or range**.
- "Can sign in from" an address that is not your website server's: open the user's menu, choose **Change who can sign in…** and pick your website server.
- Everything looks allowed but the site still cannot connect: check that the site's **Environment** uses the database server's address. If the two servers are on different private networks, use their public addresses instead (allow the website server's public address).

**"cannot reach each other"** when you choose **Create and connect**: the two servers share no private network and one of them has no public address. Put them on the same private network, or give both a public address, then try again.

**"keeps its database settings in its own files"**: Fuzops cannot fill in this kind of site. Create the database and its user on the database server (with **One other server or address** and your website server's address), then type the details into the site yourself.

**Never choose "Allow any address…" to make a problem go away.** It opens the database server to everyone on the internet. Allow the website server instead.
