Database admin: users, permissions, maintenance
Create MySQL/MariaDB users and databases, manage permissions, import/export data, monitor performance, and maintain database health.
On this page
Database administration (DBA) involves creating and managing MySQL/MariaDB databases, user accounts, permissions, backups, and performance. While UnderHost handles server-level administration, website owners need to manage their own databases.
Create a new database user
Via cPanel (easiest for shared hosting):
- Log in to cPanel
- Go to Databases → MySQL Databases
- Scroll down to "MySQL Users"
- Enter a username (cPanel prefixes with your account prefix)
- Enter a strong password (cPanel generates one if you prefer)
- Click Create User
Via phpMyAdmin (for advanced users):
- Log in to phpMyAdmin (in cPanel)
- Click the User accounts tab at the top
- Click Add user account
- Enter username, select "Local" for host, enter password
- Assign the user to a database (next step)
- Click Go
Via command line (VPS/Dedicated):
mysql -u root -p
mysql> CREATE USER 'newuser'@'localhost' IDENTIFIED BY 'strong_password_here';
mysql> FLUSH PRIVILEGES;
mysql> EXIT;
Create a new database
Via cPanel:
- Go to Databases → MySQL Databases
- Under "Create New Database", enter a database name
- Click Create Database
- cPanel adds your account prefix automatically (e.g., "accountname_mydb")
Via phpMyAdmin:
- Log in to phpMyAdmin
- Click New in the left sidebar
- Enter database name and choose charset (usually utf8mb4)
- Click Create
Via command line (VPS):
mysql -u root -p
mysql> CREATE DATABASE mysite_db CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
mysql> FLUSH PRIVILEGES;
mysql> EXIT;
Manage database permissions
Via cPanel (simplest):
- Go to Databases → MySQL Databases
- Under "Add User To Database", select user and database
- Click Add
- Check all permissions for the user
- Click Make Changes
Permission levels (what each user needs):
- WordPress user: SELECT, INSERT, UPDATE, DELETE (reading/writing posts and settings)
- Database backup user: SELECT only (backup needs read-only access)
- Application user: Depends on app (usually SELECT, INSERT, UPDATE, DELETE)
- Admin user: ALL (for administrative tools)
Important: Never use the root MySQL user for your website. Always create a limited user for each application.
Reset a database user password
Via cPanel:
- Go to Databases → MySQL Databases
- Scroll to "MySQL Users"
- Find your user and click Change Password
- Enter new password and click Change Password
Via phpMyAdmin:
- Click User accounts tab
- Find the user and click Change password
- Enter new password and click Go
Via command line (VPS):
mysql -u root -p
mysql> ALTER USER 'username'@'localhost' IDENTIFIED BY 'new_strong_password';
mysql> FLUSH PRIVILEGES;
mysql> EXIT;
If you change a database password, remember to update your application's configuration file (wp-config.php for WordPress, settings.php for Drupal, etc.) with the new password, or your site won't be able to connect to the database.
Using phpMyAdmin for administration
Access phpMyAdmin:
- Via cPanel: Home → Databases → phpMyAdmin
- Direct URL: yourdomain.com/phpmyadmin or cpanel.yourdomain.com/phpmyadmin
Common phpMyAdmin tasks:
- View tables: Click database name in left sidebar → click table to see rows
- Edit data: Click pencil icon next to any row to edit values
- Run SQL queries: Click SQL tab and paste your SQL command
- Export/backup: Click Export tab, select format (SQL), and click Go
- Import data: Click Import tab, upload your SQL file, and click Go
- Check table size: Hover over table in left sidebar or click Structure tab
Monitor database size and performance
Check database size in cPanel:
- Go to Databases → MySQL Databases
- You'll see the size of each database (in MB)
- If a database is >100MB, investigate large tables
Find large tables in phpMyAdmin:
- Click your database
- Look at the table list—each row shows size
- Sort by size to find the largest tables
- WordPress: "wp_posts" and "wp_comments" often grow large
Check query performance:
- Enable MySQL slow query log (log queries slower than 2 seconds)
- Review which queries are slow
- Add database indexes to speed up common queries
- See our MySQL performance tuning guide
Database maintenance tasks
1. Optimize tables (remove fragmentation)
Over time, database tables become fragmented. Optimizing reclaims space and speeds up queries:
Via phpMyAdmin:
- Select all tables in your database (checkboxes at bottom)
- Go to bottom dropdown and select Optimize table
- Click Go
Via command line:
mysql -u root -p databasename -e "OPTIMIZE TABLE tablename;"
2. Repair corrupted tables
If a table becomes corrupted (rare but happens), repair it:
Via phpMyAdmin:
- Right-click the table and select Repair table
Via command line:
mysqlcheck -u root -p databasename tablename
3. Regular backups
Back up your database weekly or before major changes:
- Automated: Use backup plugins for automatic daily backups
- Manual: Go to phpMyAdmin → click database → Export → download .sql file
Shared hosting vs VPS databases
| Feature | Shared Hosting | Cloud VPS |
|---|---|---|
| Database access | Via cPanel/phpMyAdmin | Command line + phpMyAdmin |
| Resource limits | Shared with other accounts | Dedicated to your VPS |
| Can restart MySQL | No (contact support) | Yes (systemctl restart mysql) |
| Tuning parameters | Limited (host-managed) | Full control |
| Large databases | Max ~2-5GB typically | Much larger possible |
| Performance | Affected by other accounts | Dedicated resources |
Common database issues
"Access denied for user" - Wrong username or password
- Verify credentials in wp-config.php match cPanel database user
- Reset password and update config file
"MySQL has gone away" - Connection lost
- Database server restarted or timed out
- Increase wait_timeout in MySQL configuration
- Check if database size is huge (slowing down queries)
"Disk quota exceeded" - Database is too large
- Database size exceeded your hosting plan limit
- Delete old data, archive to backup, or upgrade plan
✓ Create separate users for each application
✓ Use strong passwords (20+ characters)
✓ Never use root for websites
✓ Back up weekly
✓ Optimize tables monthly
✓ Monitor database size
Related articles: phpMyAdmin guide | Database backup and restore | MySQL performance tuning
Need hosting for database-backed apps?
Run WordPress, CMS, PHP apps, and MySQL/MariaDB workloads on UnderHost hosting, VPS, or managed servers.





















