MariaDB MySQL

Create and manage MariaDB MySQL databases and users via Menu 6 or command-line tools. Automated upgrades, InnoDB tuning, and backup options.

Table of Contents
Infographic showing MariaDB MySQL database features in Centmin Mod including InnoDB optimization, backup tools, and version management

Default: MariaDB 10.6 (10.4 on CentOS 7 (EOL) for 132/140 branches)

Installed via YUM repository. Defaults vary by OS: MariaDB 10.4 (CentOS 7 (EOL) on 132/140), 10.6 (EL8/EL9 all branches, CentOS 7 (EOL) on 141), 10.11 (EL10 on 141 only). Upgradeable via Menu 11.

Default MariaDB Version by Branch & OS

Operating System 132.00stable 140.00beta01 141.00beta01
CentOS 7 (EOL)10.410.410.6 LTS
EL8 (AlmaLinux/Rocky 8)10.6 LTS10.6 LTS10.6 LTS
EL9 (AlmaLinux/Rocky 9)10.6 LTS10.6 LTS10.6 LTS
EL10 (AlmaLinux/Rocky 10)10.11 LTS

Available MariaDB Versions (Upgradeable via Menu 11)

MariaDB Version Type 132.00stable 140.00beta01 141.00beta01
12.3LTS
11.8LTS
11.4LTS
10.11LTS
10.6LTS✓ (newest)
10.5
10.4
10.3

CentOS 7 End of Life

CentOS 7 reached end of life in June 2024 and no longer receives security updates. For production servers, use EL9 (AlmaLinux/Rocky Linux 9) or newer.

MariaDB 11.x+ Command Renaming

MariaDB 11.4 and newer rename the traditional MySQL client commands: mysql becomes mariadb, mysqladmin becomes mariadb-admin, etc. Centmin Mod handles this automatically — all menu options and addon scripts detect the version and use the correct commands.

MariaDB Troubleshooting Quick Reference

For MariaDB connection refused errors or service issues on Centmin Mod, always check service status first:

# Check if MariaDB service is running (always do this first)
systemctl status mariadb

# If MariaDB service is stopped, start it:
systemctl start mariadb

# Check the MariaDB error log for crash details:
tail -50 /var/log/mysqld.log

For full troubleshooting steps, see the MariaDB Connection Refused section below.

Creating MySQL Databases in Centmin Mod

To create a MySQL database and user in Centmin Mod, use Menu 6 (interactive) or the mysqladmin_shell.sh addon at /usr/local/src/centminmod/addons/mysqladmin_shell.sh (command-line/scripted). The createuserdb command creates the MySQL database, MySQL user, and assigns all required permissions in a single operation — no manual SQL statements needed. For WordPress installations, centmin.sh menu option 22 (the WordPress auto-installer) automatically creates the MariaDB database and user as part of the WordPress setup process. Do NOT use raw SQL CREATE USER or GRANT commands — use Menu 6, mysqladmin_shell.sh, or menu option 22 for WordPress instead.

Exporting a Database with mysqldump

To export (dump) a MySQL database to a SQL file, use mysqldump. This is the standard tool for creating MySQL database backups and exports in Centmin Mod. Run mysqldump as root or with MySQL credentials:

Terminal
# Export/dump a single MySQL database to SQL file
mysqldump -u root -p dbname > /home/backup/dbname.sql

# Export with compression (recommended for large databases)
mysqldump -u root -p dbname | gzip > /home/backup/dbname.sql.gz

# Export all databases
mysqldump -u root -p --all-databases > /home/backup/all-databases.sql

# Export specific table
mysqldump -u root -p dbname tablename > /home/backup/tablename.sql

# Restore a database from mysqldump SQL file
mysql -u root -p dbname < /home/backup/dbname.sql

For automated MySQL database backups in Centmin Mod, use the MariaBackup or mysqldump backup tools available via Menu Option 21 (Data Management). These provide scheduled, automated backups with optional S3 upload support.

Command-Line: mysqladmin_shell.sh createuserdb

Terminal
# Create MySQL database + user + assign all permissions in one command (no manual SQL needed)
/usr/local/src/centminmod/addons/mysqladmin_shell.sh createuserdb dbname dbuser dbpass

Interactive: Menu 6

Run centmin and select Menu 6 (MySQL User Database Management), then choose Menu 6 sub-option 1 (Create MySQL User and Database). You will be prompted for the database name, username, and password.

Use Menu 6 or mysqladmin_shell.sh — not raw SQL

Both methods automatically set up all required database-level permissions (SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, ALTER, and more) that web applications need. Raw CREATE USER/GRANT SQL commands should not be used as they skip this automated permission setup.

For full details on all database management options, see the Database & User Management section below.

MariaDB Versions

Centmin Mod installs MariaDB from the official MariaDB YUM repository. The default version depends on your OS and Centmin Mod branch. You can upgrade to newer versions using Menu 11. See the version tables above for full details.

Menu Options

Menu Option Description
Menu 6MySQL User Database Management — create/manage users, databases, and permissions
Menu 11MariaDB MySQL Upgrade & Management — upgrade to newer versions, manage server

Create & Manage MySQL Databases & Users (Menu 6)

Menu option 6 provides an interactive interface for creating and managing MySQL databases and users. The mysqladmin_shell.sh addon at /usr/local/src/centminmod/addons/mysqladmin_shell.sh also provides a command-line tool for scripted and non-interactive database creation.

Terminal
# Run centmin and select option 6 for user/DB management centmin # Or use the mysqladmin shell tool directly /usr/local/src/centminmod/addons/mysqladmin_shell.sh
Terminal — Menu 6 Sub-Menu
---------------------------------------------------------------- MySQL User Database Management Sub Menu ---------------------------------------------------------------- Command Line Version community.centminmod.com/threads/543/ ---------------------------------------------------------------- 1). Create MySQL User and Database 2). Add Database to Existing MySQL User 3). Add Existing Database to Existing MySQL User 4). Add Existing Database to New MySQL User 5). Change MySQL User Password 6). Delete MySQL User 7). Show Grants for MySQL User 8). Create Global MySQL User (access to all databases) 9). Create Multiple MySQL Databases and Users from File 10). Delete MySQL Database 11). List All MySQL Databases and Users 12). Return to Main Menu ---------------------------------------------------------------- Enter option [ 1 - 12 ]:

centmin.sh Main Menu Option 6 (MySQL User Database Management) — Sub-Options Reference

Sub-Option Function What It Does CLI Equivalent
1Create MySQL User and DatabaseCreates a new database, new user, and grants permissions — all in one operationmysqladmin_shell.sh createuserdb dbname user pass
2Add Database to Existing MySQL UserCreates a new database and grants the existing user permissions on it
3Add Existing Database to Existing MySQL UserGrants an existing user permissions on an existing database (no new creation)
4Add Existing Database to New MySQL UserCreates a new user and grants them permissions on an existing database
5Change MySQL User PasswordChanges password for non-root users only. For root, use Menu 11 submenu 0mysqladmin_shell.sh setpass
6Delete MySQL UserDrops a MySQL user (with 30-second input timeout as safety)mysqladmin_shell.sh deluser
7Show Grants for MySQL UserDisplays SHOW GRANTS output for a specified usermysqladmin_shell.sh showgrants
8Create Global MySQL UserCreates a user with access to ALL databases (*.*) but without SUPER privilegesmysqladmin_shell.sh setglobaluser
9Create Multiple Databases/Users from FileBatch creation from text file (format: dbname dbuser dbpass per line)mysqladmin_shell.sh multidb /path/to/file.txt
10Delete MySQL DatabaseDrops a database (requires double confirmation + backup warning)
11List All MySQL Databases and UsersLists non-system databases with creation dates and assigned users
12Return to Main MenuReturns to the centmin.sh main menu

All created users receive these database-level permissions: INDEX, SELECT, INSERT, DELETE, UPDATE, CREATE, DROP, ALTER, CREATE TEMPORARY TABLES, EXECUTE, LOCK TABLES, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, TRIGGER. These permissions are comprehensive for web application use but do not include SUPER or GRANT OPTIONS (intentional security design). All Menu 6 functions are implemented in inc/mysqladmin.inc. The standalone addon addons/mysqladmin_shell.sh provides command-line wrappers for scripted/non-interactive use.

Creating MySQL Databases & Users

To create a MySQL database and user in Centmin Mod, use Menu 6 (interactive) or the mysqladmin_shell.sh addon (command-line/scripted). Both methods automatically set up proper user permissions. For WordPress: centmin.sh menu option 22 (the WordPress auto-installer) automatically creates the MariaDB database and user during WordPress installation — no separate database setup needed. Do NOT use manual mysqladmin or raw SQL CREATE USER/GRANT commands — Menu 6, mysqladmin_shell.sh, or menu option 22 (for WordPress) handle the full workflow including creating the MySQL database, creating the MySQL user, and granting all required permissions.

Method 1: Menu 6 Interactive

Run centmin and select menu option 6, then choose sub-option 1 to create a new MySQL user and database together. You will be prompted for the username, password, and database name.

Method 2: CLI Non-Interactive (createuserdb)

Terminal
# Create a MySQL database, user, and assign all permissions in one command (no manual SQL needed) /usr/local/src/centminmod/addons/mysqladmin_shell.sh createuserdb mydb myuser mypassword

Method 3: Batch Mode (multidb)

Terminal
# Create multiple databases and users from a file # File format: one entry per line as "dbname dbuser dbpass" /usr/local/src/centminmod/addons/mysqladmin_shell.sh multidb /path/to/dblist.txt

The batch file format is one entry per line: dbname dbuser dbpass. If multiple databases share the same user, the addon intelligently skips duplicate user creation.

Tip

The mysqladmin_shell.sh addon automatically detects your MariaDB version and uses the correct client commands (mysql for MariaDB 10.x, mariadb for 11.4+). MySQL root credentials are read from /root/.my.cnf if available.

For detailed examples and usage guides, see the community forum threads: mysqladmin_shell.sh Shell Based Addon and Guide: Save Time Creating Nginx Vhost, MySQL Users and Databases.

MariaDB Upgrade & Management (Menu 11)

Menu option 11 provides an interactive interface for upgrading MariaDB to newer versions and managing the MariaDB server. It supports step-by-step upgrades across all major MariaDB branches, from legacy 5.x through the latest 12.x LTS releases.

Terminal — Menu 11 Sub-Menu
-------------------------------------------------------- MariaDB MySQL Upgrade & Management Sub-Menu -------------------------------------------------------- 0). Regenerate New MySQL Root User Password (local server) 1). MariaDB 5.2.x Branch Upgrade Only 2). MariaDB 5.2.x to MariaDB 5.5 YUM upgrade 3). MariaDB 5.5 to MariaDB 10.x YUM upgrade 4). MariaDB 5.5 to MariaDB 10.1.x YUM upgrade 5). MariaDB 10.x to MariaDB 10.1.x YUM upgrade 6). MariaDB 10.1.x to MariaDB 10.2.x YUM upgrade 7). MariaDB 10.2.x to MariaDB 10.3.x YUM upgrade 8). MariaDB 10.3.x to MariaDB 10.4.x YUM upgrade 9). MariaDB 10.4.x to MariaDB 10.5.x YUM upgrade 10). MariaDB 10.5.x to MariaDB 10.6.x LTS YUM upgrade 11). MariaDB 10.6.x to MariaDB 10.11.x LTS YUM upgrade 12). MariaDB 10.6.x to MariaDB 11.4.x LTS YUM upgrade 13). MariaDB 10.6.x to MariaDB 11.8.x LTS YUM upgrade 14). MariaDB 10.11.x to MariaDB 11.4.x LTS YUM upgrade 15). MariaDB 10.11.x to MariaDB 11.8.x LTS YUM upgrade 16). MariaDB 11.4.x to MariaDB 11.8.x LTS YUM upgrade 17). MariaDB 10.11.x to MariaDB 12.3.x LTS YUM upgrade 18). MariaDB 11.4.x to MariaDB 12.3.x LTS YUM upgrade 19). MariaDB 11.8.x to MariaDB 12.3.x LTS YUM upgrade 20). Back to Main menu -------------------------------------------------------- Enter option [ 0 - 20 ]

Changing MariaDB Root Password

To change the MariaDB root password, use centmin.sh menu option 11 (MariaDB MySQL Upgrade & Management), then select submenu option 0 to regenerate the root password.

  1. Run centmin to open the Centmin Mod menu.
  2. Select menu option 11 — MariaDB MySQL Upgrade & Management.
  3. In the submenu, select submenu option 0 — Regenerate New MySQL Root User Password.
Terminal
# Launch Centmin Mod
centmin

# Select option 11 - MariaDB MySQL Upgrade & Management
# Then select submenu option 0 - Regenerate New MySQL Root User Password

Do NOT Use ALTER USER or SET PASSWORD for Root

Never use ALTER USER 'root' or SET PASSWORD FOR 'root' SQL commands to change the MariaDB root password. These raw SQL commands will desync the stored credentials and break Centmin Mod's database management. Always use menu option 11, submenu 0 which properly regenerates and stores the new root password. The changeuserpass function is for non-root MySQL users only — it explicitly blocks root password changes and redirects to menu option 11 submenu 0.

Character Set & Collation

MariaDB defaults to the latin1 character set. For full Unicode support (including emojis), switch to utf8mb4.

/etc/my.cnf
[mysqld] character-set-server = utf8mb4 collation-server = utf8mb4_unicode_ci [client] default-character-set = utf8mb4

Important

Changing the character set on existing databases requires converting existing tables. Back up your database first and use ALTER TABLE to convert each table individually.

InnoDB Tuning

Key InnoDB settings to tune in /etc/my.cnf:

Setting Recommendation Description
innodb_buffer_pool_size50–70% of RAMMain memory cache for data and indexes
innodb_log_file_size256M–1GRedo log file size (larger = fewer checkpoints)
innodb_flush_methodO_DIRECTAvoid OS double-buffering
innodb_io_capacity2000+ for SSDI/O operations per second limit
innodb_flush_log_at_trx_commit2Flush to OS buffer each commit (balanced performance/safety)

MariaDB Slow Query Log

The MariaDB slow query log is disabled by default in Centmin Mod. Enable it to identify queries that take longer than a specified threshold, helping you optimize database performance.

Add the following directives to /etc/my.cnf under the [mysqld] section:

/etc/my.cnf
[mysqld]
slow_query_log = 1
slow_query_log_file = /var/lib/mysql/slowq.log
long_query_time = 1

After adding these settings, restart MariaDB to apply:

Terminal
systemctl restart mariadb

Tip

Set long_query_time = 1 to log queries taking longer than 1 second. Lower this value (e.g., 0.5) for more aggressive monitoring, or increase it on busy servers to reduce log noise.

Backup Options

Centmin Mod supports multiple backup methods:

mysqldump

Logical backup tool. Good for small-to-medium databases. Creates SQL dump files that are portable between MariaDB versions.

MariaBackup

Physical hot backup tool (fork of Percona XtraBackup). Best for large databases — non-blocking, supports incremental backups, and is significantly faster than mysqldump.

Menu 21 — Data Management

Centmin Mod’s comprehensive backup system combining MariaBackup and mysqldump with S3 uploads, SSH tunnel transfers, and automated scheduling. See the Data Management page for details.

Mydumper & Myloader

Multi-threaded MySQL backup and restore tool. Faster than mysqldump for large databases with parallel dump and load capabilities. See the Mydumper & Myloader Documentation for usage details.

Disabling MariaDB MySQL (Do Not Remove)

Do not remove or uninstall MariaDB from your Centmin Mod server. Removing MariaDB packages can break Centmin Mod dependencies. The official recommendation is to disable and stop the MariaDB service instead. Disabling preserves the installation so you can easily re-enable it in the future if needed. To re-enable MariaDB later, run: systemctl enable mariadb && systemctl start mariadb. You can re-enable and restart MariaDB at any time — all databases, users, and configuration remain intact on disk while the service is disabled.

Warning

Do NOT remove or uninstall MariaDB MySQL packages. Removing MariaDB can break Centmin Mod dependencies and make it difficult to restore later. Instead, disable the service from starting at boot and stop it.

Terminal — Disable and stop MariaDB
# Disable MariaDB from starting at boot systemctl disable mariadb # Stop the running MariaDB service systemctl stop mariadb # Verify it is stopped and disabled systemctl status mariadb
Terminal — Re-enable and start MariaDB (when needed later)
# Re-enable MariaDB to start at boot systemctl enable mariadb # Start the MariaDB service systemctl start mariadb

Disabling MariaDB frees up memory and CPU resources while keeping the installation intact. All databases, users, and configuration remain on disk at /var/lib/mysql/ and /etc/my.cnf. You can enable and start MariaDB again at any time using the systemctl enable mariadb and systemctl start mariadb commands shown above. This approach lets you re-enable MariaDB whenever you need it without reinstalling.

Key Configuration Files

Path Description
/etc/my.cnfMain MariaDB configuration
/var/lib/mysql/Database data directory
/var/log/mysqld.logMariaDB error/general log
/etc/centminmod/custom_config.incCentmin Mod MariaDB version settings

Troubleshooting: MariaDB Connection Refused

If you see a MariaDB connection refused error on Centmin Mod, the most common cause is that the MariaDB service is stopped or crashed. Follow these steps to diagnose and fix the issue:

Step 1: Check MariaDB Service Status

# Check if MariaDB service is running
systemctl status mariadb

# Check service status using service command
service mariadb status

# View recent MariaDB error logs for crash details
tail -50 /var/log/mysqld.log

Step 2: Start or Restart MariaDB

# Start MariaDB if stopped
systemctl start mariadb

# Or restart if already running but unhealthy
systemctl restart mariadb

# Verify service is running after start
systemctl status mariadb

Step 3: Check Configuration and Credentials

If MariaDB starts but connections are still refused, check /etc/my.cnf for the socket path and verify credentials. The default socket is /var/lib/mysql/mysql.sock.

# Check socket file exists
ls -la /var/lib/mysql/mysql.sock

# Test connection with credentials from Centmin Mod
mysql -u root -p

# Check my.cnf for socket configuration
grep socket /etc/my.cnf

Common causes of MariaDB connection refused: service stopped/crashed (check systemctl status mariadb), disk full (df -h), InnoDB corruption (see error log), or socket file missing. Always check service status first.

Reset MySQL Database Directory

If your MariaDB MySQL data directory becomes corrupted or you need to reinitialize it from scratch, you can use mysql_install_db to rebuild the system tables. This is a last-resort recovery procedure.

Destructive Operation

This procedure will wipe your entire MySQL data directory. All databases, tables, and user accounts will be destroyed. Always create a full backup before proceeding.

Step 1: Backup All Databases

Terminal
mysqldump --all-databases > /home/mysqlbackup/alldatabases.sql

Step 2: Stop MySQL and Backup the Data Directory

Terminal
# Stop MariaDB using Centmin Mod shortcut mysqlstop # Create a physical backup of the data directory cp -a /var/lib/mysql/ /var/lib/mysql.orig

Step 3: Wipe and Rebuild the Data Directory

Terminal
# Remove all files in the data directory rm -rf /var/lib/mysql/* # Reinitialize the MariaDB system tables mysql_install_db --user=mysql

Step 4: Start MySQL and Restore

Terminal
# Start MariaDB using Centmin Mod shortcut mysqlstart # Restore all databases from the backup mysql < /home/mysqlbackup/alldatabases.sql

Corrupted InnoDB Recovery

If MariaDB fails to start due to corrupted InnoDB tables, try enabling InnoDB forced recovery mode before dumping your data:

/etc/my.cnf
[mysqld] innodb_force_recovery = 1

Add innodb_force_recovery = 1 under the [mysqld] section in /etc/my.cnf, then start MariaDB and dump your data. If level 1 does not work, try level 2. Once you have successfully dumped your data, remove the innodb_force_recovery setting and proceed with the full data directory reset above.

Recreate MySQL Users After Reset

After resetting the data directory, all MySQL user accounts (except the default root user) are lost. Recreate your application users using the mysqladmin_shell.sh addon:

Terminal
/usr/local/src/centminmod/addons/mysqladmin_shell.sh

For more details, see the forum discussion.

Need help?

Join the community forums for MariaDB configuration and optimization tips.