# Move your data in or out

> Copy a database from another host into Phluit, or take a copy out, with pg_dump and pg_restore or mysqldump.

Source: https://docs.phluit.com/products/managed-databases/move-your-data-in/

Run these commands from a computer or server that's on the database's [trusted sources](/products/managed-databases/trusted-sources/), with the CA certificate from the **Connect** tab next to them.

## PostgreSQL

```sh
# copy out of the old database
pg_dump --format=custom --no-owner "postgres://USER:PASSWORD@OLD-HOST:5432/DBNAME" > dump.pgc

# load into your Phluit database
PGPASSWORD="$DB_PASSWORD" pg_restore --no-owner \
  --dbname "host=HOST port=PORT user=dbadmin dbname=defaultdb sslmode=verify-ca sslrootcert=ca-certificate.crt" dump.pgc
```

## MySQL

```sh
# copy out of the old database
mysqldump --single-transaction --routines --triggers -h OLD-HOST -u USER -p DBNAME > dump.sql

# load into your Phluit database
MYSQL_PWD="$DB_PASSWORD" mysql -h HOST -P PORT -u dbadmin --ssl-mode=VERIFY_CA --ssl-ca=ca-certificate.crt defaultdb < dump.sql
```

Every MySQL table needs a primary key: add one to tables without it before you load them.

## Taking a copy out

The same tools work the other way round: run `pg_dump` or `mysqldump` against your Phluit database to keep a copy of your own.

Need a hand with a move? [Open a ticket](https://portal.phluit.com/tickets/create).
