This guide explains how to create, manage, and back up MySQL or MariaDB databases in Virtualmin. Databases are essential for web applications like WordPress, Joomla, or custom scripts, and you can manage them without root access using the Virtualmin control panel.
Prerequisites
- Virtualmin Access: You must have login credentials for the Virtualmin control panel.
- Domain Configured: The domain associated with your databases must be set up in Virtualmin.
- Database Feature Enabled: Ensure the database feature is active for your domain (usually enabled by default).
Step-by-Step Guide
1. Log in to Virtualmin
Access the Virtualmin control panel with your credentials. Select the domain you want to manage from the dropdown menu in the top-left corner.
2. Create a New Database
- Navigate to Database Management:
- In the sidebar, click
Edit Databases
orManage Databases
(depending on your Virtualmin version).
- In the sidebar, click
- Add a Database:
- Click
Create a new database
or a similar button. - Database Name: Enter a name (e.g.,
wordpress_db
). It will be prefixed with your domain or username (e.g.,yourdomain_wordpress_db
). - Database Type: Select
MySQL
orMariaDB
(usually MySQL is default). - Leave other settings as default unless you have specific requirements.
- Click
- Save:
- Click
Create
to create the database.
- Click
3. Create a Database User
- Access User Settings:
- In
Edit Databases
, select the database you created, then clickManage
orDatabase Users
.
- In
- Add a User:
- Click
Add a new database user
. - Username: Enter a username (e.g.,
wp_user
). It may be prefixed like the database name. - Password: Set a strong password.
- Permissions: Grant
All privileges
for the user to manage the database fully (recommended for web applications).
- Click
- Save:
- Click
Create
to add the user and link them to the database.
- Click
4. Access the Database
- Using phpMyAdmin:
- In the Virtualmin sidebar, click
phpMyAdmin
(often underEdit Databases
orWebmin
). - Log in with the database username and password you created.
- Use phpMyAdmin to manage tables, run queries, or import/export data.
- In the Virtualmin sidebar, click
- Connecting from an Application:
- Configure your web application (e.g., WordPress) with the following details:
- Database Name: The name you created (e.g.,
yourdomain_wordpress_db
). - Username: The database user (e.g.,
yourdomain_wp_user
). - Password: The user’s password.
- Host: Usually
localhost
(confirm with support if unsure).
- Database Name: The name you created (e.g.,
- Configure your web application (e.g., WordPress) with the following details:
5. Back Up and Restore a Database
- Backup:
- In
Edit Databases
, select the database and clickBackup
. - Choose a destination (e.g., download to your computer or save to a server directory like
/home/yourdomain/backups
). - Click
Backup Now
to create a.sql
file.
- In
- Restore:
- In
Edit Databases
, select the database and clickRestore
. - Upload the
.sql
backup file or specify its server path. - Click
Restore Now
to restore the database.
- In
6. Delete a Database
- Locate the Database:
- In
Edit Databases
, find the database you want to delete.
- In
- Delete:
- Click
Delete
next to the database. - Confirm deletion. Note: This will permanently remove the database and its data unless backed up.
- Click
Additional Tips
- Security:
- Use strong passwords for database users.
- Limit database user permissions to only what’s needed for specific applications.
- Regular Backups:
- Schedule automatic database backups in Virtualmin to prevent data loss.
- Database Naming:
- Use descriptive names (e.g.,
wordpress_db
) to easily identify databases.
- Use descriptive names (e.g.,
Common Troubleshooting
- Cannot Access phpMyAdmin: Verify the database username and password. Ensure phpMyAdmin is enabled (contact support if unavailable).
- Application Connection Errors: Check the database name, username, password, and host in your application’s configuration file.
- Database Full: If you hit storage limits, contact support to check your account’s database quota.
For further assistance, contact our support team via the ShopWhizzy Helpdesk.