CLOUD
Guides

Database Management in cPanel: MySQL Made Easy

CLOUD|November 10, 2025|4 min read|620 views
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)

  1. cPanel, then Databases, then MySQL Databases
  2. In the "Create New Database" field, enter the database name
  3. Click "Create Database"
  4. The database name will be: username_dbname (cPanel automatically adds username_)

Creating a Database User

On the same page:

  1. Scroll to the "MySQL Users" section
  2. Enter the username and a strong password
  3. Click "Create User"
  4. In the "Add User To Database" section: choose the user and database
  5. 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:

  1. cPanel, then Databases, then Remote MySQL
  2. Add the source IP (your machine's IP or external server)
  3. 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:

  1. Select the database
  2. Check All tables
  3. 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:

  1. Select the database
  2. Export, then Custom, select SQL, then Go
  3. 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:

  1. Export: mysqldump -u user -p dbname > export.sql
  2. Transfer the file to the new server: scp export.sql user@newserver:/home/
  3. Create a new database with the same name (or a different name)
  4. Import: mysql -u user -p newdbname < export.sql
  5. Update application config or .env with 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.

Share