{% extends "base.html" %} {% import "_macros.html" as m with context %} {% block title %}Databases{% endblock %} {% block content %}

Databases

Each database gets a login with the same name. It signs in with a password or with a key.

{{ m.icon("db") }}Open Adminer
{% if dbs %}
{% if is_admin %}{% endif %} {% for d in dbs %} {% if is_admin %}{% endif %} {% endfor %}
Name and loginAccountEngineSign-inSize
{{ d.name }}{{ m.copy(d.name) }}{% if d.site %}in {{ d.site }}{% if d.auth == "password" %}, open in Adminer{% endif %}{% endif %}{{ d.owner }}{{ d.engine_label }} {% if d.auth == "key" %}{{ m.icon("key") }}Key{% else %}Password{% endif %} {{ d.size|size }} {% for kind in ("password", "key") %}
{{ m.csrf_field() }}
{% endfor %}
{{ m.csrf_field() }}
{% else %} {% call m.empty("No databases yet", "Create one for WordPress, a shop or your own app. The password is shown once, right after you create it.") %} {% endcall %} {% endif %}
{% if dbs|selectattr("auth", "equalto", "key")|list %}

Connecting with a key

Use no password. Databases of a container website: host db or postgres, folder /var/www/private/db-keys/DATABASE. Databases on the server: host 127.0.0.1, as below.

$dir = '/home/ACCOUNT/db-keys/DATABASE';

// MariaDB
$db = new PDO('mysql:host=127.0.0.1;dbname=DATABASE', 'DATABASE', '', [
    PDO::MYSQL_ATTR_SSL_KEY  => "$dir/client.key",
    PDO::MYSQL_ATTR_SSL_CERT => "$dir/client.crt",
    PDO::MYSQL_ATTR_SSL_CA   => "$dir/ca.crt",
]);

// PostgreSQL
$db = new PDO("pgsql:host=127.0.0.1;dbname=DATABASE;sslmode=verify-full;"
    . "sslkey=$dir/client.key;sslcert=$dir/client.crt;sslrootcert=$dir/ca.crt", 'DATABASE');
{% endif %} {% endblock %}