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.
MySQL vs MariaDB
Section titled “MySQL vs MariaDB”| Feature | MySQL | MariaDB |
|---|---|---|
| Maintainer | Oracle | Community (original MySQL creator) |
| License | GPL + Commercial | GPL |
| Compatibility | — | Fully compatible with MySQL |
| Strengths | Stable, wide support | More open-source features, performance improvements |
Creating a Database
Section titled “Creating a Database”- Navigate to the “Databases” page in the dashboard
- Select “MySQL” or “MariaDB”
- Choose a version
- Configure parameters:
| Parameter | Description |
|---|---|
| Root password | MySQL root account password |
| Database name | Initially created database |
| Username | Application account |
| User password | Application account password |
Connection Settings
Section titled “Connection Settings”# MySQL connection stringmysql://user:password@mysql-container:3306/myapp
# MariaDB connection string (same format)mysql://user:password@mariadb-container:3306/myappCommon Framework Examples
Section titled “Common Framework Examples”// Node.js (mysql2)const mysql = require('mysql2/promise');const connection = await mysql.createConnection(process.env.DATABASE_URL);# Python (PyMySQL)import pymysqlconnection = pymysql.connect( host='mysql-container', user='user', password='password', database='myapp')// PHP (PDO)$pdo = new PDO( 'mysql:host=mysql-container;dbname=myapp', 'user', 'password');Performance Tuning
Section titled “Performance Tuning”Key Parameters
Section titled “Key Parameters”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 sizeinnodb_log_file_size = 256M
# Maximum connectionsmax_connections = 150
# Query cache (removed in MySQL 8.0)# MariaDB still supports itquery_cache_size = 64MData Import and Export
Section titled “Data Import and Export”Export
Section titled “Export”# Export a single databasemysqldump -u root -p myapp > backup.sql
# Export all databasesmysqldump -u root -p --all-databases > all_backup.sqlImport
Section titled “Import”# Import a databasemysql -u root -p myapp < backup.sqlCommon Issues
Section titled “Common Issues”Character Encoding Problems
Section titled “Character Encoding Problems”Ensure the database uses the UTF-8 character set:
-- Specify character set when creating databaseCREATE DATABASE myapp CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
-- Check existing database character setSHOW CREATE DATABASE myapp;Too Many Connections
Section titled “Too Many Connections”If you encounter a Too many connections error:
- Increase the
max_connectionssetting - Check if your application properly closes database connections
- Use connection pooling to manage connections