How to Install PlanetScale Database: Step-by-Step Guide
PlanetScale is a powerful, distributed database built on Vitess that offers scalable and serverless MySQL-compatible cloud database solutions. This tutorial walks you through the process of installing and setting up PlanetScale to leverage its advanced database capabilities effectively.
Prerequisites
- A computer with internet access
- Command line interface (CLI) knowledge
- A PlanetScale account (sign up here if you haven’t already)
- Git installed on your machine (for CLI authentication if using GitHub login)
- Basic understanding of MySQL databases
Step 1: Sign Up and Log In to PlanetScale
Visit PlanetScale (Official site) and create an account if you do not have one. After signing up, log into your dashboard to access the PlanetScale platform.
Step 2: Install the PlanetScale CLI
The PlanetScale CLI (command-line interface) enables you to manage your PlanetScale databases locally and remotely. Install it on your computer using the following method based on your operating system:
- For macOS: Run
brew install planetscale/tap/pscaleif you have Homebrew installed. - For Windows: Download the executable from the PlanetScale GitHub repository or use
scoop install pscaleif you use Scoop. - For Linux: Download the binary from the GitHub releases page or install using package managers supported.
Verify the installation by running:
pscale --version
Step 3: Authenticate CLI with Your PlanetScale Account
Log in via the CLI to link it with your PlanetScale account:
pscale auth login
This will open a browser window prompting you to authenticate. Complete the login process, and your CLI will be authorized.
Step 4: Create a New PlanetScale Database
To create a database, use the CLI command:
pscale database create your-database-name --region your-region
Replace your-database-name with your preferred name and your-region with a supported region like us-east, eu-west, etc.
Step 5: Connect to Your PlanetScale Database
After creation, create a branch to isolate development or production work:
pscale branch create your-database-name your-branch-name
Connect locally using the following command to open a secure MySQL shell:
pscale connect your-database-name your-branch-name
This opens a connection where you can run standard MySQL commands on your PlanetScale database.
Step 6: Integrate PlanetScale with Your Application
To use PlanetScale in your app, obtain connection credentials from the PlanetScale dashboard or CLI, and configure your MySQL client or ORM accordingly. Check pscale password create for creating connection passwords.
Troubleshooting Tips
- Authentication issues: Ensure that your CLI is logged in and tokens are valid.
- Connection errors: Verify branch names and database status in the dashboard.
- CLI installation problems: Confirm system PATH includes the CLI location.
Summary Checklist
- Sign up for PlanetScale and log in
- Install the PlanetScale CLI for your OS
- Authenticate the CLI with your account
- Create a new database and branch
- Connect to your database securely using CLI
- Configure your app with connection credentials
For related insights on cloud database installations, you may find our guide on How to Install FaunaDB useful as it covers similar installation workflows.
With these steps, you’re ready to leverage PlanetScale for scalable and modern database solutions in your projects.
