How to connect to PlanetScale with Adminer

Date Published

Time Commitment

1 minute

Ego Number

26 views

Once challenge you will face trying to connect to a PlanetScale database with Adminer is that it requires an SSL connection, which Adminer does not use by default. Not to worry, there's a plugin for that.

  1. Download Adminer
  2. Download the login-ssl.php plugin
  3. Download the plugin.php file
  4. Create a folder called adminer and mimic the structure below:
adminer/
    adminer.php
    index.php
    plugins/
        login-ssl.php
        plugin.php
  1. Find the path to your SSL certificate here
  2. Put the following inside index.php:
<?php
function adminer_object() {
    include_once(__DIR__ . "/plugins/plugin.php");

    foreach (glob(__DIR__ . "/plugins/*.php") as $file) {
        include_once($file);
    }

    return new AdminerPlugin([
        new AdminerLoginSsl(['ca' => 'YOUR_CERTIFICATE_PATH_HERE'])
    ]);
}

include './adminer.php';
  1. Connect to the PlanetScale database as you would a local MySQL database, except use the URL from PlanetScale as the host (ending in psdb.cloud)