Client Area

Import MySQL Database in cPanel Create DB & User, phpMyAdmin Import, App Connection

6 min readPublished 4 Mar 2026Updated 16 Apr 2026556 views

In this article

  • 1QuickStart Checklist (At a Glance)
  • 2Why this guide
  • 3Prerequisites
  • 4Understand cPanel Prefixes (Important)
  • 51) Create the Database

Create DB Create User Grant Access Import via phpMyAdmin Connect Your App

For shared hosting & VPS on cPanel. Screens/labels vary slightly by theme. No SSH required.


QuickStart Checklist (At a Glance)

  • Create Database: cPanel MySQL Databases Create New Database

  • Create User: cPanel MySQL Databases MySQL Users Add New User

  • Grant Privileges: Add User to Database ALL PRIVILEGES (or leastprivilege)

  • Import: cPanel phpMyAdmin select DB Import pick .sql / .sql.gz Go

  • Connect App: host localhost, DB name, user, password` update config/.env

Estimated time: 5-10 minutes
Works for: WordPress, Laravel, Magento, custom PHP apps, etc.


Why this guide

Migrating or restoring a website often starts with the database. This stepbystep cPanel guide shows you exactly how to create a MySQL database and user, assign privileges, import with phpMyAdmin, and connect your application--all without SSH. Ideal for shared hosting and VPS environments, these instructions help you avoid common errors like Access denied, Unknown collation, and MySQL server has gone away while following security best practices.

Target keywords: import MySQL database in cPanel, phpMyAdmin import, create MySQL user in cPanel, WordPress database restore, cPanel database migration, shared hosting MySQL, VPS MySQL setup.


Prerequisites

  • A database dump: .sql (preferred) or compressed .sql.gz / .zip

  • Know the character set/collation used in the dump (e.g., utf8mb4)

  • cPanel login for the target account

Tip: If your dump includes triggers/views, ensure the export included routines.


Understand cPanel Prefixes (Important)

Many cPanel servers autoprefix names with your cPanel username:

  • Database cpuser_appdb

  • User cpuser_appuser

Use the full prefixed names in application configs and during imports.


1) Create the Database

  1. Log in to cPanel open MySQL Databases

  2. Under Create New Database, enter a short name (e.g., appdb) Create Database

  3. Note the full name shown (e.g., cpuser_appdb) Go Back

Keep names short; avoid spaces/special characters.


2) Create a MySQL User

  1. In MySQL Databases, scroll to MySQL Users Add New User

  2. Enter a username (e.g., appuser) and generate a strong password

  3. Click Create User Go Back

Best practices

  • Use a unique user per application

  • Rotate passwords after staff changes or incidents


3) Grant the User Access to the Database

  1. In Add User To Database, pick the user and database

  2. Click Add

  3. On the privileges screen:

    • ALL PRIVILEGES for initial setup/import, or

    • Leastprivilege (SELECT/INSERT/UPDATE/DELETE; plus CREATE/ALTER/INDEX for migrations)

  4. Make Changes

You can tighten privileges after the import.


4) Import the Database with phpMyAdmin

  1. Return to cPanel Home open phpMyAdmin

  2. In the left sidebar, click your database (it will be empty)

  3. Click the Import tab

  4. Choose File select your dump (.sql or .sql.gz)

  5. Confirm Format = SQL; set Character set to utf8mb4 if applicable

  6. (Optional) Enable Partial import to help with long uploads

  7. Scroll down Go

File Size Limits & Large Imports (No SSH)

  • Compress to .sql.gz and retry

  • Split the dump into smaller chunks and import sequentially

  • If enabled by your host: cPanel Backup Restore a MySQL Database

  • Open a support ticket for serverside import if the file is very large

If you see timeouts (MySQL server has gone away), try .sql.gz or ask support to raise limits temporarily.


5) Connect Your Application (DB Credentials)

Most apps need four values:

  • DB host: usually localhost

  • DB name: e.g., cpuser_appdb

  • DB user: e.g., cpuser_appuser

  • DB password: the strong password you created

PHP (mysqli) connection test

<php
$host = 'localhost';
$db = 'cpuser_appdb';
$user = 'cpuser_appuser';
$pass = 'REPLACE_WITH_STRONG_PASSWORD';

$con = mysqli_connect($host, $user, $pass, $db);
if (!$con) {
 die('Connection failed: ' . mysqli_connect_error());
}
echo 'Connected successfully and database selected!';
mysqli_close($con);

PHP (PDO) connection test

<php
$dsn = 'mysql:host=localhost;dbname=cpuser_appdb;charset=utf8mb4';
$user = 'cpuser_appuser';
$pass = 'REPLACE_WITH_STRONG_PASSWORD';

try {
 $pdo = new PDO($dsn, $user, $pass, [PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION]);
 echo 'Connected with PDO!';
} catch (PDOException $e) {
 echo 'Connection failed: ' . $e->getMessage();
}

Sample .env (generic PHP app)

DB_HOST=localhost
DB_DATABASE=cpuser_appdb
DB_USERNAME=cpuser_appuser
DB_PASSWORD=REPLACE_WITH_STRONG_PASSWORD
DB_CHARSET=utf8mb4
DB_COLLATION=utf8mb4_unicode_ci

After updating configs, clear application caches and retest.


6) PostImport Verification (QA)

  • Row counts: open key tables in phpMyAdmin; confirm expected counts

  • Charset & collation: ensure utf8mb4/utf8mb4_unicode_ci where required

  • Routines/Triggers/Views: present and valid

  • Time zones: check displayed timestamps; align app/server time zone if needed

  • Functional test: log in to the app, navigate core pages, submit a form


7) Common Errors & Fixes

Access denied for user
Wrong DB name/user/password, or user not attached. Reattach user and retest.

MySQL server has gone away / timeout
File too large or slow. Use .sql.gz, split the dump, or request serverside import.

Unknown collation (e.g., utf8mb4_0900_ai_ci)
Target MySQL/MariaDB older than source. Reexport with common collation (e.g., utf8mb4_general_ci) or replace collation strings in the dump, then import.

Foreign key constraint errors
Creation order conflicts. Wrap dump with:

SET FOREIGN_KEY_CHECKS=0;
-- your schema + data here
SET FOREIGN_KEY_CHECKS=1;

Duplicate entry for key
Target has existing data. Drop conflicting tables first, or import into a fresh DB.

#1044 - Access denied to database
Insufficient privileges. Temporarily grant ALL PRIVILEGES, import, then tighten.


8) Security & Maintenance Best Practices

  • Unique DB user per app; never reuse across projects

  • Least privilege in production (remove CREATE/ALTER if not needed)

  • Keep dumps clean (no test admin users or debug data)

  • Store credentials securely; rotate after staff changes

  • Schedule backups before major updates/migrations


FAQ

Q1: Where do I find phpMyAdmin in cPanel
A: From cPanel Home, open phpMyAdmin under the Databases section.

Q2: What is my MySQL host
A: Usually localhost in cPanel environments. If remote DB is enabled, your host may differ.

Q3: Can I import a .sql.zip file
A: Prefer .sql or .sql.gz. Some phpMyAdmin builds accept .zip, but .gz is more reliable.

Q4: My file is bigger than the upload limit. What now
A: Compress to .sql.gz, split into parts, or ask hosting support for a serverside import.

Q5: I see Access denied after import--what changed
A: Ensure the user is attached to the database and the prefix matches (cpuser_...).


Need Help from Domain India


Learn how to import a MySQL database in cPanel stepbystep: create database and user, assign privileges, import with phpMyAdmin, and connect your app. Perfect for shared hosting & VPS.
cPanel MySQL import, phpMyAdmin import, create MySQL user cPanel, WordPress database restore, shared hosting MySQL, VPS MySQL database setup, database migration cPanel.


Appendix: Formats & Options

  • .sql - raw SQL; most portable

  • .sql.gz - compressed; best for large imports via phpMyAdmin

  • Partial import - helps resume long uploads

  • Definer fixes - replace DEFINER=\olduser`@`%`withCURRENT_USER` in views/triggers if needed


Summary

You've created a database and user in cPanel, granted privileges, imported your .sql with phpMyAdmin, and connected your app using the correct prefixed credentials. Follow the QA checks and best practices above for a stable, secure deployment.

Was this article helpful?

Your feedback helps us improve our documentation

Still need help? Submit a support ticket