Skip to content

MySQL / MariaDB

MySQL is one of the most widely used open-source relational databases, and MariaDB is its fully compatible community fork. Piora supports both — choose based on your preference.

FeatureMySQLMariaDB
MaintainerOracleCommunity (original MySQL creator)
LicenseGPL + CommercialGPL
CompatibilityFully compatible with MySQL
StrengthsStable, wide supportMore open-source features, performance improvements
  1. Navigate to the “Databases” page in the dashboard
  2. Select “MySQL” or “MariaDB”
  3. Choose a version
  4. Configure parameters:
ParameterDescription
Root passwordMySQL root account password
Database nameInitially created database
UsernameApplication account
User passwordApplication account password
Terminal window
# MySQL connection string
mysql://user:password@mysql-container:3306/myapp
# MariaDB connection string (same format)
mysql://user:password@mariadb-container:3306/myapp
// Node.js (mysql2)
const mysql = require('mysql2/promise');
const connection = await mysql.createConnection(process.env.DATABASE_URL);
# Python (PyMySQL)
import pymysql
connection = pymysql.connect(
host='mysql-container',
user='user',
password='password',
database='myapp'
)
// PHP (PDO)
$pdo = new PDO(
'mysql:host=mysql-container;dbname=myapp',
'user',
'password'
);

Adjust the following MySQL parameters based on your VPS specs:

# Buffer pool size (recommended: 50-70% of available memory)
innodb_buffer_pool_size = 512M
# Log file size
innodb_log_file_size = 256M
# Maximum connections
max_connections = 150
# Query cache (removed in MySQL 8.0)
# MariaDB still supports it
query_cache_size = 64M
Terminal window
# Export a single database
mysqldump -u root -p myapp > backup.sql
# Export all databases
mysqldump -u root -p --all-databases > all_backup.sql
Terminal window
# Import a database
mysql -u root -p myapp < backup.sql

Ensure the database uses the UTF-8 character set:

-- Specify character set when creating database
CREATE DATABASE myapp CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
-- Check existing database character set
SHOW CREATE DATABASE myapp;

If you encounter a Too many connections error:

  1. Increase the max_connections setting
  2. Check if your application properly closes database connections
  3. Use connection pooling to manage connections