-
I had to install PlanetScale CLI following: https://planetscale.com/docs/concepts/planetscale-environment-setup
-
I logged in using
pscale auth
command:
$ pscale auth login
# this opened my browser where I was logged in on PlanetScale
- I checked with my database name and production branch
$ pscale shell database1 main
# my database name: database1
# my production branch: main
database1/main: show tables;
# and some other sql queries
- I took a backup in the
./dump
directory
$ pscale database dump database1 main --output dump
Starting to dump all tables from database database1 to folder dump
Dumping is finished! (elapsed time: 4.458032834s)
It looked like this in dump directory:
$ find dump
dump
dump/database1.table-name-1.00001.sql
dump/database1.table-name-1-schema.sql
dump/database1.table-name.00001.sql
dump/database1.table-name-2-schema.sql
dump/database1.table-name-2-schema.sql
dump/database1.table-name-2.00001.sql
dump/metadata
- I merged all schema files into one file:
$ cat dump/database1*schema*.sql > dump/schema.sql
# notice database1 is my own database name, you might have a different one so edit accordingly
- I merged other files that don't have schema in their names into one seed file:
$ ls dump/*.sql | grep -v 'schema' | xargs cat > dump/seed_without_schema.sql
- Finally I imported the SQL files in my other hosted MySQL databases.