CEOHOST · DATABASE & CPANEL

How to Import a Large SQL Database in cPanel

Learn how to import a large MySQL .sql database on cPanel when the normal phpMyAdmin upload method is limited by file size, timeout or PHP restrictions.

▶ Watch the Tutorial

Watch the complete video before starting the database import.

Why Use This Method?

Large database files can sometimes fail when imported directly through phpMyAdmin because of PHP upload limits, execution time limits, memory restrictions or server-level restrictions.

Instead of uploading the database through the phpMyAdmin import form, this method uploads the .sql file directly to your hosting account and uses a PHP importer to process the database on the server.

What You Need

✓ cPanel Access

Access to File Manager and MySQL Databases.

✓ SQL Backup

Your database backup in .sql format.

✓ MySQL Database

A database and database user with permissions.

✓ PHP Importer

The import.php file provided below.

DOWNLOAD RESOURCE

Large SQL Importer — import.php

Download the PHP importer used in this tutorial. Configure it with your own database details before running it.

Download import.php

File hosted on MediaFire.

1. Create a MySQL Database

Log in to cPanel and open MySQL® Databases.

Create a database and database user, then assign the user to the database with the required privileges.

You should have:

  • Database Host
  • Database Name
  • Database Username
  • Database Password

On most cPanel hosting environments, the database host is:

localhost

2. Upload Your SQL Database

Open cPanel → File Manager and navigate to the directory where you want to perform the import.

Upload your large SQL backup file.

For example:

database.sql

For the easiest setup, keep import.php and the SQL file in the same directory.

public_html/
├── import.php
└── database.sql

3. Configure import.php

Open import.php and replace the database information with your own credentials.

$host = "localhost";
$username = "YOUR_DATABASE_USERNAME";
$password = "YOUR_DATABASE_PASSWORD";
$database = "YOUR_DATABASE_NAME";
$sqlFilePath = __DIR__ . "/database.sql";
⚠ Security Warning

Never use or publish someone else's database credentials. Replace all example credentials with your own before using the importer.

4. Upload import.php

Upload the configured import.php file into the same directory as your SQL database.

public_html/import.php
public_html/database.sql

5. Start the Database Import

Open the importer in your browser.

https://yourdomain.com/import.php

The PHP script will connect to the MySQL database and begin processing the SQL file.

Depending on the size of the database and the server configuration, the import may take some time.

6. Monitor the Import

The importer displays the progress while the SQL file is being processed.

???? Tip

Do not close the browser or stop the script while the import is running.

7. Verify the Database

Once the import has completed, open phpMyAdmin from cPanel and select your database.

Verify that the expected tables and data are present.

Common phpMyAdmin Limitations

  • Maximum upload size
  • upload_max_filesize
  • post_max_size
  • memory_limit
  • max_execution_time
  • Web server timeout
  • phpMyAdmin import restrictions

Important Compatibility Information

This PHP importer is designed for many standard SQL database dumps. However, not every SQL dump format is guaranteed to work with a simple PHP importer.

Problems may occur with databases containing:

  • Stored procedures
  • Triggers
  • Custom delimiters
  • Complex SQL statements
  • Database-specific commands

For very large or complex databases, an SSH-based MySQL import may be more suitable if SSH access is available.

⚠ Important Security Notice

Do not leave import.php publicly accessible after the database import is complete.

  • Delete import.php after the migration.
  • Remove the SQL backup from the public web directory when it is no longer required.
  • Never expose database credentials through a public PHP file.
  • Do not leave your SQL backup accessible through a public URL.
  • Keep a secure copy of your original database backup.

Troubleshooting

Error / Problem What to Check
SQL file not found Check the SQL filename and the path configured in import.php.
Database connection failed Verify the database host, database name, username, password and user privileges.
Import stops during processing The SQL dump may contain syntax or structures that the importer cannot process.
Script timeout Your hosting provider may enforce a server-level execution limit.

Database Migration Complete?

Once the database has been successfully imported, verify your website/application and remove the temporary importer and SQL backup from publicly accessible locations.

Need Help With Your Migration?

If you need assistance with cPanel, database migration or hosting configuration, contact our support team.

Contact Ceohost Support
Răspunsul a fost util? 7611 utilizatori au considerat informația utilă (90987 Voturi)