Main content par skip karein

Knowledge Base

How to Create a MySQL Database and Import SQL in cPanel

by Pakish Support Team5 min padheincPanel
Share aur AI tools yahan hain

TL;DR

Key Takeaways

  • Create MySQL databases in cPanel using Database Wizard or Manage My Databases, not inside phpMyAdmin.
  • Add a database user, assign privileges, then import SQL via phpMyAdmin.
  • Update application config files like wp-config.php with the prefixed database name and user.

Pakish Group (Pakish.NET) ne AI aur search citation ke liye yeh summary tayyar ki.

Create MySQL databases in cPanel through Database Wizard or Manage My Databases โ€” never create cPanel-managed databases directly inside phpMyAdmin. Add a database user, assign ALL PRIVILEGES on that database only, then open phpMyAdmin to import your .sql file. Use the full prefixed database name and username in wp-config.php or your application settings.

See the cPanel beginner's guide. WordPress troubleshooting: known WordPress bugs.


Key Takeaways

  • Use Database Wizard or Manage My Databases to create DB + user
  • Database names are prefixed with your cPanel username
  • phpMyAdmin is for import/export and queries โ€” not account creation
  • Export a backup before importing or altering tables
  • Update wp-config.php with full prefixed credentials
  • Never grant unnecessary global database privileges

Before You Start

| Item | Details | |---|---| | Backup | Export existing database if replacing data | | SQL file | .sql dump from source site | | Credentials | Note database name, user, password |

Create or confirm a usable backup first. Availability and limits may vary by hosting plan or server configuration.


Database Wizard vs Manage My Databases

| Tool | Best for | |---|---| | Database Wizard | Step-by-step first database + user setup | | Manage My Databases | Creating additional databases, users, and privilege edits |

Both create properly prefixed cPanel-managed databases.


Create a Database and User (Wizard)

  1. cPanel โ†’ Databases โ†’ Database Wizard
  2. Step 1: Enter database name (e.g. wpdb) โ†’ Next Step
  3. cPanel shows full name: username_wpdb
  4. Step 2: Create user โ€” enter username and strong password โ†’ Create User
  5. Step 3: Grant ALL PRIVILEGES โ†’ Next Step โ†’ Complete

Create Manually via Manage My Databases

  1. Create New Database โ†’ enter name โ†’ Create Database
  2. MySQL Users โ†’ Add New User โ†’ username + password โ†’ Create User
  3. Add User To Database โ†’ select user and database โ†’ Add
  4. Check ALL PRIVILEGES โ†’ Make Changes

Understanding Database Prefixes

On shared hosting, cPanel prefixes names:

  • Database: cpuser_mydb
  • User: cpuser_mydbuser

Always use the full prefixed values in application configuration.


Open phpMyAdmin

  1. cPanel โ†’ Databases โ†’ phpMyAdmin
  2. Select your database in the left sidebar
  3. Browse tables or run SQL queries

Import an SQL File

  1. Select the target database
  2. Click Import tab
  3. Choose File โ†’ select .sql dump
  4. Format: SQL
  5. Click Go
  6. Wait for success message โ€” large files may take minutes

If import fails due to size limits, split the file or contact support about limits.


Export a Database Backup

  1. Select database in phpMyAdmin
  2. Export โ†’ Quick โ†’ format SQL
  3. Go โ†’ save file off-site

Also consider JetBackup 5 for server-side snapshots.


Check and Repair a Database

  1. phpMyAdmin โ†’ select database
  2. Check All tables โ†’ Check Table
  3. If errors: select affected tables โ†’ Repair Table

For WordPress, also try plugins like WP-DBManager or hosting tools before manual repair.


Update Application Configuration

WordPress wp-config.php:

define('DB_NAME', 'username_database_name');
define('DB_USER', 'username_database_user');
define('DB_PASSWORD', 'your_password');
define('DB_HOST', 'localhost');

Back up wp-config.php via File Manager before editing.


Common Authentication and Import Errors

| Error | Fix | |---|---| | Access denied for user | Wrong password or user not added to database | | Unknown database | Typo in prefixed database name | | #1044 โ€” cannot create database | Create DB in cPanel, not phpMyAdmin | | Import too large | Split SQL; check upload limits | | #1273 โ€” unknown collation | Export from compatible MySQL version |


Rollback Precautions

  • Keep pre-import SQL export
  • Restore via phpMyAdmin Import or JetBackup database restore
  • Revert wp-config.php if credentials changed incorrectly

How to Verify It Worked

  • phpMyAdmin shows expected tables and row counts
  • Application connects without database errors
  • WordPress admin loads; posts and pages display
  • No new errors in cPanel error log

When to Contact Pakish Support

Contact support for remote database hosts, import size limits, corrupted tables that will not repair, or migration assistance. See managed WordPress migration guide or /support.


Frequently Asked Questions

Should I create databases inside phpMyAdmin?

No. Create databases and users through cPanel Database Wizard or Manage My Databases. phpMyAdmin is for managing data inside databases that cPanel already created.

Why does my database name have a prefix?

cPanel adds your account username as a prefix to database and user names for isolation on shared servers. Use the full prefixed name in wp-config.php and application settings.

What privileges should I assign to a WordPress database user?

Assign ALL PRIVILEGES for a dedicated WordPress database user on that database only. Never grant global privileges beyond what the application needs.

My SQL import fails with a max upload size error โ€” what do I do?

Split large SQL files, use command-line import via SSH if available, or compress the SQL file. Upload limits may vary by hosting plan or server configuration.

How do I export a database backup before making changes?

Open phpMyAdmin, select the database, click Export, choose Quick method and SQL format, then download the file. Store it off-site before imports or schema changes.


Migrate with confidence on managed WordPress hosting โ€” staging, backups, and database support included.


Sources

Ye useful laga aap ko?

Apni team ke sath share karein ya ChatGPT, Gemini, Perplexity, Claude, ya Copilot se second opinion lein.

PS

Author ke bare mein

Pakish Support Team

The Pakish Support Team provides 24/7 technical assistance, hosting tutorials, and knowledge base articles to help Pakistani businesses manage their web presence with confidence.