Databases
Create and connect to a database
Create a MariaDB database in the panel, save its password, and connect to it from PHP, WordPress or a Python app.
Learning path · step 12 of 20
On this page
Most dynamic websites keep their content in a database: WordPress posts, shop orders, user accounts. FiniteHost web hosting plans include MariaDB databases, a drop-in replacement for MySQL that works with WordPress and any PHP app written for MySQL.
Before you start#
- Databases come with web hosting plans (Spark and above). Python compute and mail plans do not include databases.
- The plan must be Active to create a database.
- Have a safe place ready for the password, such as a password manager. It is shown only once.
How databases are named#
You choose a short name, and FiniteHost puts your subscription ID in front of it so names never clash between customers. The user name is the same as the database name.
| You type | Database name | User name |
|---|---|---|
wordpress | t3d2ca2b860_wordpress | t3d2ca2b860_wordpress |
shop | t3d2ca2b860_shop | t3d2ca2b860_shop |
A name is 2 to 16 characters: lowercase letters, digits or _, starting with a letter.
Create a database#
- Open Databases in the panel sidebar under Data & files.
- Type a name in Create a database, for example
wordpress. - Click Create database.
- Copy the details from the Database created dialog: the database, the user and the password.
- Click I have copied it. The database shows as Being set up.
- Wait about a minute until its state changes to Ready. The page refreshes on its own.
Connection details#
| Setting | Value |
|---|---|
| Engine | MariaDB |
| Host | localhost |
| Port | 3306 |
| Database | t3d2ca2b860_wordpress (yours, from the panel) |
| User | Same as the database name |
| Password | The one from the dialog |
| Character set | utf8mb4 (collation utf8mb4_unicode_ci), so every language and emoji works |
Databases are reachable only from your own websites and Python apps on FiniteHost, through localhost. You cannot connect from your own computer with a desktop tool such as MySQL Workbench or HeidiSQL: there is no remote database access. To move data in or out, see Import and export a database.
Connect from PHP#
Keep the password out of your public folder. Put the settings in a file next to public (see Folder layout), for example /sites/acme.in/private/db.php:
<?php
return [
'host' => 'localhost',
'name' => 't3d2ca2b860_shop',
'user' => 't3d2ca2b860_shop',
'pass' => 'paste-the-password-here',
];Then connect with PDO, the recommended way:
<?php
$cfg = require __DIR__ . '/../private/db.php';
$pdo = new PDO(
"mysql:host={$cfg['host']};dbname={$cfg['name']};charset=utf8mb4",
$cfg['user'],
$cfg['pass'],
[
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
]
);
$stmt = $pdo->prepare('SELECT name, price FROM products WHERE id = ?');
$stmt->execute([42]);
$product = $stmt->fetch();Or with mysqli:
<?php
$cfg = require __DIR__ . '/../private/db.php';
mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
$db = new mysqli($cfg['host'], $cfg['user'], $cfg['pass'], $cfg['name']);
$db->set_charset('utf8mb4');Connect from WordPress#
WordPress asks for these during installation, or you set them in wp-config.php:
define( 'DB_NAME', 't3d2ca2b860_wordpress' );
define( 'DB_USER', 't3d2ca2b860_wordpress' );
define( 'DB_PASSWORD', 'paste-the-password-here' );
define( 'DB_HOST', 'localhost' );
define( 'DB_CHARSET', 'utf8mb4' );The full walk-through is in Install WordPress.
Connect from a Python app#
Python apps on a web hosting plan (Pro and above include apps) run on the same server as your databases, so they connect through localhost too. Add the driver to your app's requirements.txt:
PyMySQL==1.1.1import pymysql
conn = pymysql.connect(
host="localhost", port=3306,
user="t3d2ca2b860_shop", password="paste-the-password-here",
database="t3d2ca2b860_shop", charset="utf8mb4",
)
with conn.cursor() as cur:
cur.execute("SELECT COUNT(*) FROM products")
print(cur.fetchone()[0])
conn.close()Python compute plans (Compute Nano to Large) have no databases. An app can store data in files inside its own folder instead, for example with Python's built-in sqlite3.
Troubleshooting#
- Access denied for user: check the user name includes your subscription ID, and that you copied the whole password. If unsure, make a new password.
- Unknown database: the database is still Being set up. Wait a minute for Ready.
- Can't connect from my computer: that is expected; there is no remote access. Use a tool that runs on your site instead.
- Too many connections or slow queries: see Database limits and passwords.
More fixes are in Database problems.
What's next#
Was this helpful?
Still stuck?
Email support@finitehost.com with your subscription ID (it starts with t, shown on the panel's Dashboard) and what you tried. A person replies, usually within one business day.
Last updated 27 October 2026. Found something wrong? Tell support@finitehost.com.