Overview
The mysqladmin_shell.sh addon provides a scriptable command-line interface for common MariaDB MySQL administration tasks on Centmin Mod servers. It wraps the MySQL admin operations needed when provisioning web applications — creating databases, setting up users, granting privileges — into simple one-line commands that work unattended in scripts or interactively via centmin.sh menu option 6 or centmin.sh menu option 22 (WordPress auto-installer, which automatically creates the database, user, and grants privileges).
The script is located at /usr/local/src/centminmod/addons/mysqladmin_shell.sh and supports MariaDB 10.x through 11.x. On MariaDB 10.11 and later, it automatically uses the mariadb command alias instead of mysql.
Key Features
- Create a database + user + password in a single command (
createuserdb) - Batch-create multiple databases from a plain-text file (
multidb) - Interactive guided database/user setup (
setuserdb) - Grant global admin privileges (
setglobaluser) - Change user passwords (
setpass) - Remove users (
deluser) - Inspect user privileges (
showgrants) - Integrated with Centmin Mod Menu Option 6
MariaDB 10.11+ Compatibility: On servers running MariaDB 10.11 or later, Centmin Mod automatically detects the version and uses the mariadb client command (the preferred alias). This is handled transparently — no changes needed in your scripts.
Installation & Access
The script is included with Centmin Mod and requires no additional installation. It uses the MariaDB root credentials from /root/.my.cnf (configured during Centmin Mod installation) to authenticate automatically — no password prompts needed.
# Script location
/usr/local/src/centminmod/addons/mysqladmin_shell.sh
# Run from the centminmod source directory
cd /usr/local/src/centminmod
addons/mysqladmin_shell.sh [subcommand] [args...]
# View help / all subcommands
addons/mysqladmin_shell.sh
Running the script with no arguments (or with an unrecognized subcommand) prints the help text listing all available subcommands and their usage.
createuserdb — Create Database + User
The createuserdb subcommand creates a new database, a new MariaDB user, and grants the user full privileges on that database in a single non-interactive command. It is ideal for scripting application deployments, including creating a MariaDB database and user for WordPress.
Tip: You can also create databases via centmin.sh menu option 22 (WordPress auto-installer), which automatically creates the database, user, and installs WordPress in one step. For manual database creation without WordPress, use mysqladmin_shell.sh createuserdb shown below.
Syntax
addons/mysqladmin_shell.sh createuserdb DBNAME DBUSER DBPASS
Example
# Create database 'wpdb', user 'wpuser' with password 'mySecurePass123'
addons/mysqladmin_shell.sh createuserdb wpdb wpuser mySecurePass123
# Internally creates database, user, and grants all required permissions in one step
Password Security: Passing passwords on the command line stores them in shell history. For sensitive environments, use the interactive setuserdb command instead, or pre-clear history after running: history -c.
setuserdb — Interactive Database Setup
The setuserdb subcommand launches an interactive prompt that guides you through setting up a database-user relationship. It offers 5 sub-options for different scenarios:
addons/mysqladmin_shell.sh setuserdb
| Option | Description |
|---|---|
| 1 | Create new database and new user |
| 2 | Create new database and grant access to an existing user |
| 3 | Grant an existing user access to an existing database |
| 4 | Create a new user and grant access to an existing database |
| 5 | Exit / cancel |
The interactive mode is convenient for occasional one-off provisioning tasks where you want guided prompts rather than remembering argument order. For scripted automation, use createuserdb or multidb instead.
multidb — Batch Database Creation
The multidb subcommand reads a plain-text file and creates multiple databases and users in one pass. Each line in the file represents one database entry.
File Format
One entry per line with three space-separated fields: databasename databaseuser databasepassword
# Format: databasename databaseuser databasepassword
wp_site1 wp_user1 Pass1!secure
app_staging app_stage StagePass99
shop_db shop_user ShopPass!2026
Usage
addons/mysqladmin_shell.sh multidb /path/to/dblist.txt
The script processes each line and calls the equivalent of createuserdb for each entry. Useful when migrating multiple sites, setting up a staging environment, or provisioning clients in bulk.
setglobaluser — Global Privileges
The setglobaluser subcommand creates a MariaDB user with broad privileges on all databases (*.*). The command is interactive — it prompts for username and password. This is appropriate for admin or backup users that need access to every database on the server.
addons/mysqladmin_shell.sh setglobaluser
# Prompts: Enter new MySQL username you want to create:
# Prompts: Enter new MySQL username's password:
# Grants on *.*: SELECT, INSERT, UPDATE, DELETE, CREATE, DROP,
# INDEX, ALTER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE,
# CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, TRIGGER
Use with caution: Global privileges grant access to all databases. Only use setglobaluser for dedicated admin or backup accounts. Note: SUPER, RELOAD, CREATE USER, GRANT, PROCESS, and REPLICATION privileges are not included. Application users should be scoped to a single database using createuserdb instead.
setpass / deluser / showgrants
setpass — Change Password
Change the password for an existing MariaDB user. The command is interactive — it prompts for the username and new password:
addons/mysqladmin_shell.sh setpass
# Prompts: Enter MySQL username you want to change password for:
# Prompts: Enter MySQL username's new password to change to:
deluser — Delete User
Remove a MariaDB user account (does not drop associated databases). The command is interactive with a 30-second timeout:
addons/mysqladmin_shell.sh deluser
# Prompts: Enter MySQL username you want to delete (type exit to abort):
showgrants — Show Privileges
Display the GRANT statements for a user — useful for auditing what access a user has. The command is interactive:
addons/mysqladmin_shell.sh showgrants
# Prompts: Enter MySQL username to show grants for:
# Example output
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER,
CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, CREATE VIEW, SHOW VIEW,
CREATE ROUTINE, ALTER ROUTINE, TRIGGER ON `wpdb`.* TO 'wpuser'@'localhost'
Subcommands Reference
| Subcommand | Arguments | Description |
|---|---|---|
| createuserdb | DBNAME DBUSER DBPASS | Create database + user + grant all privileges (non-interactive) |
| setuserdb | (interactive) | Interactive guided database/user setup with 5 sub-options |
| multidb | FILENAME | Batch create databases from a text file (one entry per line) |
| setglobaluser | (interactive) | Create user with broad privileges on *.* (global access, prompts for username/password) |
| setpass | (interactive) | Change password for an existing user (prompts for username and new password) |
| deluser | (interactive) | Remove a MariaDB user account (prompts for username, 30s timeout) |
| showgrants | (interactive) | Show GRANT privileges for a user (prompts for username) |