Managing Databases in Virtualmin

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

  1. Navigate to Database Management:
    • In the sidebar, click Edit Databases or Manage Databases (depending on your Virtualmin version).
  2. 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 or MariaDB (usually MySQL is default).
    • Leave other settings as default unless you have specific requirements.
  3. Save:
    • Click Create to create the database.

3. Create a Database User

  1. Access User Settings:
    • In Edit Databases, select the database you created, then click Manage or Database Users.
  2. 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).
  3. Save:
    • Click Create to add the user and link them to the database.

4. Access the Database

  1. Using phpMyAdmin:
    • In the Virtualmin sidebar, click phpMyAdmin (often under Edit Databases or Webmin).
    • Log in with the database username and password you created.
    • Use phpMyAdmin to manage tables, run queries, or import/export data.
  2. 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).

5. Back Up and Restore a Database

  • Backup:
    • In Edit Databases, select the database and click Backup.
    • 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.
  • Restore:
    • In Edit Databases, select the database and click Restore.
    • Upload the .sql backup file or specify its server path.
    • Click Restore Now to restore the database.

6. Delete a Database

  1. Locate the Database:
    • In Edit Databases, find the database you want to delete.
  2. Delete:
    • Click Delete next to the database.
    • Confirm deletion. Note: This will permanently remove the database and its data unless backed up.

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.

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.

Categories: Database
thumb-up thumb-down