MySQL import errors almost always come down to three things: the file is too large for the server's limits, the character set of the file does not match the database, or the collation in the file does not exist on the server. Each one has a different error message and a different fix, so read the message before you try anything.

We import databases constantly — moving a Laravel script to a new host, restoring a backup, setting up a demo — and these three errors account for nearly every failed import we see. This guide covers each one, in the order you are most likely to meet it.

What does "file too large" actually mean?

When phpMyAdmin refuses your SQL file, it is not the database complaining. It is PHP's upload limit. Shared hosting typically caps uploads at a few megabytes, and a real database export is often far bigger than that. The error usually appears the moment you press import, before a single row is read.

The fix depends on what access you have. If you have SSH, skip the browser entirely and import from the command line:

mysql -u username -p database_name < backup.sql

The command line has no upload limit, and it is faster too. If you only have cPanel, check whether the file can be split, or compress it — phpMyAdmin accepts gzipped SQL files, and a plain SQL dump often compresses to a tenth of its size. A 50 MB dump can become a 5 MB gzip file, which may fit under the limit where the raw file did not.

If neither option works, ask your host to raise the limit, or use cPanel's backup restore instead of phpMyAdmin. One thing we do not recommend: editing the SQL file to remove rows by hand. It is easy to break the file's structure, and a half-edited dump fails in confusing ways halfway through the import.

How do you fix "unknown collation" errors?

This is the classic move-between-servers error. Your export was made on a newer MySQL or MariaDB that uses a collation your destination server does not know, and the import stops with an error like Unknown collation: 'utf8mb4_0900_ai_ci'. The file is fine; the destination server is simply older than the source.

The practical fix is to replace the collation in the file with one the destination understands. Open the SQL file in a text editor and replace utf8mb4_0900_ai_ci with utf8mb4_unicode_ci, and do the same for utf8mb4_0900_as_cs if it appears. On the command line, sed does it in one pass:

sed -i 's/utf8mb4_0900_ai_ci/utf8mb4_unicode_ci/g; s/utf8mb4_0900_as_cs/utf8mb4_unicode_ci/g' backup.sql

Then import again. The same problem can appear in the other direction: a file that declares a collation the destination has, but with a character set the table was created with differently. If the error names a collation you do not recognise, check which MySQL or MariaDB version the destination runs — cPanel shows it in the database section — and compare it with the source. Matching the versions, or exporting with the older server's collation in mind, prevents the problem at the source.

Avoid the temptation to import with the wrong collation and fix it later. Collation decides how text is sorted and compared, and a table created with the wrong one can return wrong results for searches and ordering, especially with non-English text.

What about charset mismatches and garbled text?

Charset problems are sneakier than collation errors, because the import succeeds and the damage only shows afterwards: question marks or odd symbols where your text used to be. This happens when the file was exported in one character set and imported as another — the classic case is a Latin-1 export imported into a utf8mb4 database, or the reverse.

Prevention beats repair here. When you export from phpMyAdmin, make sure the export character set matches the database, and when you create the destination database, set it to utf8mb4 with utf8mb4_unicode_ci collation before you import anything. In Laravel, the database connection in config/database.php sets the charset, and .env carries DB_CHARSET and DB_COLLATION — those values should match what the database actually uses, or you will get the same garbled-text problem from the application side even with a perfect import.

If the text is already garbled, do not keep importing over it hoping it will fix itself. Drop the tables, fix the character set on the database, and import the original file again. Trying to repair garbled text after the fact is slow, unreliable work, and a clean re-import takes minutes.

What if the import stops halfway with a timeout?

Large imports through phpMyAdmin can hit PHP's max_execution_time, and the import simply stops partway through, leaving half your tables behind. The error is often vague, or the page just goes blank. The command-line import does not have this problem, which is another reason to prefer it for anything over a few megabytes.

If you must use phpMyAdmin, import in smaller pieces: export the database table by table, or use the partial import option and resume from where it stopped. And always check afterwards that the import actually finished — count the tables and compare them with the source. A half-imported database can look fine on the homepage and then fail the moment a user opens a page that needs a missing table.

How do you import a MySQL database correctly, every time?

A short routine covers nearly all of it:

  • Create the destination database first, with utf8mb4 charset and utf8mb4_unicode_ci collation.
  • Use the command line when you can; use a gzipped file in phpMyAdmin when you cannot.
  • Match the collation to the destination server version before you import.
  • Check the import finished: compare table counts and row counts with the source.
  • Update .env with the new database name, username and password, then run php artisan config:clear.
  • Keep the original export file until the site is verified working.

The last point is the one that saves people. A failed import is a five-minute problem if you still have the original file, and a lost-data problem if you do not. Keep the export until the site is running on the new database.

If your import problem came from moving a script to a new host, our cPanel installation guide walks through the full setup, and the 9 common errors after installation guide covers the .env and permission mistakes that follow a move. A 500 error after uploading a Laravel script is also often a database connection problem in disguise — check the steps there if the import succeeded and the site still will not load. And if you are still stuck, our support is a real human on WhatsApp at +92 333 4916432, or by email at contact@zqdevelopers.com. You can also check the FAQs for the most common setup questions.