It's not obvious how to create a database using pg create

That’s all. I don’t see anything about it in the docs, and I don’t know why I have to ssh into my vm to do it when everything else can be done via cli

1 Like

Thank you for the link to the Postgres setup documentation.

My question was about creating a new database from the cli, without remotely entering the instance.

Can you please highlight or show me a screenshot of where it shows how to create a new Postgres databsase? Thank you :blush:

Hi @preciouso

The linked documentation above walks you through creating a new Postgres database from the command line. It starts with:

To create a Postgres cluster, use the fly postgres create command. The command will walk you through the creation with prompts for name, region, and VM resources.

You run the above command from your terminal, not by connecting to a VM.

Yes, I understand that, I’ve already ran the command to create an instance. But if I want to create a database called “accountdata”, for example, how do I do it without running the psql instruction CREATE DATABSE “accountdata”;?

That isnt clear in the documentation.

If you have a running app that you want to connect to your Postgres cluster, then you can run:
fly pg attach <postgres app name> -a <name of app to connect>

This command will do a few things, including creating a new database and user.

Otherwise, you would work with cluster directly using psql commands. You can connect directly with fly pg connect -a <postgres app name>.

Thank you! I wish there was a way to manually specify the database name but this is neat too

Was just digging around and it looks like you can specify the db name and the user name as options with the fly pg attach command. fly postgres attach · Fly Docs

Ooh this is super good thank you!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.