Database Management in cPanel: MySQL Made Easy

Create database, add user, permissions, phpMyAdmin — all basic MySQL operations from cPanel.
Managing Databases in cPanel: Complete Guide
Databases are the heart of any web application. Managing them correctly means better performance, secure data, and the ability to diagnose errors. cPanel provides an integrated interface for all of this without needing complex SQL commands in most cases.
Creating a MySQL Database
Standard Method (MySQL Databases)
- cPanel, then Databases, then MySQL Databases
- In the "Create New Database" field, enter the database name
- Click "Create Database"
- The database name will be:
username_dbname(cPanel automatically adds username_)
Creating a Database User
On the same page:
- Scroll to the "MySQL Users" section
- Enter the username and a strong password
- Click "Create User"
- In the "Add User To Database" section: choose the user and database
- Select permissions — for standard applications choose "All Privileges"
Security tip: Do not use a user with ALL PRIVILEGES for a read-only application. Create a user with SELECT permission only if the application does not need to write.
MySQL Database Wizard
A faster alternative: cPanel, then Databases, then MySQL Database Wizard. It walks you through step by step: create DB, create User, assign Privileges in three screens.
phpMyAdmin — Visual Management
phpMyAdmin is the most widely used tool for visually managing MySQL.
Access: cPanel, then Databases, then phpMyAdmin. Opens in a new tab, logged in automatically without an additional password.
Basic Operations
Browsing data:
- Select the database from the sidebar
- Select the table
- "Browse" tab to see data
Running an SQL query:
- "SQL" tab
- Write the query and click "Go"
-- Example: View the top 10 best-selling products
SELECT product_name, COUNT(*) as order_count
FROM order_items
GROUP BY product_name
ORDER BY order_count DESC
LIMIT 10;
Exporting a single table:
- Select the table, then Export, then Quick, then Go
- Downloads a .sql file for that table only
User Permissions — Understanding the Types
| Permission | What it means | When to use |
|---|---|---|
| SELECT | Read only | Read applications, analytics dashboards |
| INSERT | Add data | E-commerce (adding orders) |
| UPDATE | Modify data | Updating profiles |
| DELETE | Delete data | Content management |
| ALL PRIVILEGES | Everything | Full applications, assess risks first |
Remote Database Access
For database access from an external server or your local machine:
- cPanel, then Databases, then Remote MySQL
- Add the source IP (your machine's IP or external server)
- Use the connection details:
- Host: server IP (cannot use localhost from outside)
- Port: 3306
- User/Pass: credentials of the user you created
Security warning: Do not add % (any IP) in Remote MySQL in production environments. Specify only allowed IPs.
Table Optimization
Tables become "fragmented" over time, especially with frequent deletions and insertions.
In phpMyAdmin:
- Select the database
- Check All tables
- From the dropdown at the bottom of the page select "Optimize table"
Scheduling automatic optimization:
# Cron Job: optimize database tables weekly every Sunday at 2 AM
0 2 * * 0 mysqlcheck -o -u dbuser -p"dbpassword" dbname
Database Backup from phpMyAdmin
Export a full database:
- Select the database
- Export, then Custom, select SQL, then Go
- For backups: enable "Add DROP TABLE" to ensure a clean restoration
Or from SSH (for large tables):
# Export with immediate compression
mysqldump -u dbuser -p"dbpassword" dbname | gzip > backup_$(date +%Y%m%d).sql.gz
# Restore
gunzip < backup_20260101.sql.gz | mysql -u dbuser -p"dbpassword" dbname
Migrating a Database Between Hosting Accounts
From كلاود or elsewhere to a new server:
- Export:
mysqldump -u user -p dbname > export.sql - Transfer the file to the new server:
scp export.sql user@newserver:/home/ - Create a new database with the same name (or a different name)
- Import:
mysql -u user -p newdbname < export.sql - Update
application configor.envwith the new credentials
Common Problems and Solutions
"Too many connections": Reduce max_connections in MySQL settings, or use connection pooling in your application.
Slow database: Check the Slow Query Log, add Indexes to columns used in WHERE and JOIN.
"Access denied for user": Make sure the user is added to the database in MySQL Users. Simply creating the user is not enough — it must be assigned to the DB.
Proper database management from the start saves you costly performance and security problems later.
Get Started
Want to try it yourself? Choose the right hosting plan or build your custom server with the specs you need.
