Skip to content

Connect any app


In this tutorial, you'll learn how to connect any application to your PlanetScale database, with passwords or client certificates.


  • Install the PlanetScale CLI.
  • Authenticate the CLI with the following command:
pscale auth login

Connect to your database

Connect using passwords

You can also create passwords in the PlanetScale UI as documented here

Using the CLI to create a password

  1. Run the following command in the CLI to create a password for your branch.
pscale password create your-db-name main production-password
  1. Take note of the values it returns to you.
Password production-password was successfully created.
Please save the values below as they will not be shown again
--------------------- -------------- ----------------------------------- ------------------ -------------------------------------------------------
production-password jp71f987awnod Can Read & Write pscale_pw_sVkiE_mtfxQirc4qGZXMf098as90d8as0d98asd
  1. In your application's mysql config, use the following to connect:

    • host: <ACCESS HOST URL>
    • port: 3306
    • user: <USERNAME>
    • password: <PLAIN TEXT>
    • database: your-db-name
  2. Ensure you correctly configure TLS / SSL for your specific MySQL driver. See Connecting to PlanetScale securely for more information.

Connect using client certificates

You can use the pscale connect command to establish a secure connection to PlanetScale. It will listen on a local port that your application can connect to.

  1. Run the following command in the CLI:
pscale connect your-db-name main

This establishes a secure connection and opens a port on your local machine that you can use to connect any MySQL client.

  1. Take note of the address it returns to you. By default it is The CLI will use a different port if 3306 is unavailable.

  2. In your application's mysql config, use the following to connect:

    • host:
    • port: 3306 (the value returned to you by pscale connect)
    • user: root
    • password: leave this blank
    • database: your-db-name


In this tutorial, we learned :

  1. how to use pscale connect to establish a connection to our database.
  2. how to use pscale password to create a password to connect to our database.

Further reading

If you're interested in learning how to secure your application when connecting to PlanetScale, please read Connecting to PlanetScale securely

What's next?

Now that you've successfully connected your application to PlanetScale, it's time to make schema changes to your tables and deploy your application! Learn more about how PlanetScale allows you to make non-blocking schema changes to your database tables, without locking or causing downtime for production databases.

Need help?

Get help from PlanetScale's support team, or join our GitHub Discussion board to see how others are using PlanetScale.

Was this page useful?
Last updated on October 25, 2021
Help us improve this page
PrivacyTerms© 2021 PlanetScale Inc.