Tutorial
How to import a database with phpMyAdmin
Move a MySQL dump into a new host, and get past the upload size limit that stops most imports.
- Create an empty database in phpMyAdmin before you start the import.
- Compress your SQL file with gzip to stay under the 2 MB upload limit.
- Export and import using the same character set, preferably utf8mb4, to avoid garbled text.
- Update your application’s config file with the new database credentials after the import.
You need an empty database before you import anything. The import does not create it. If you do not have one ready, the import screen will fail with no useful error. Follow the guide to creating a MySQL database first, then come back here.
The actual import is three clicks once you are in phpMyAdmin. Click the database name on the left, click the Import tab, choose your file, and click Go. The rest of this article is about the two things that will stop you: the upload size limit and the character set.
The upload limit is 2 MB
phpMyAdmin runs through the web server. The web server has a limit on how large a single uploaded file can be. On CWP free hosting that limit is 2 MB. If your SQL file is bigger than that, the page will reload with no error, or you will see the 413 Payload Too Large error.
The fix is to compress the file. Gzip compresses SQL dumps very well. A 50 MB database dump often becomes a 1 MB gzip file. Export your database with gzip compression from your old host, or run gzip dump.sql on the command line if you have shell access there. phpMyAdmin can read .sql.gz files directly. Just upload the compressed file and it will decompress it during import.
If the compressed file is still above 2 MB, your database is too large for this method. You can split the dump into smaller chunks with tools like mysqldump --where, or you can ask your new host for a different import method. CWP free hosting does not offer SSH or command-line MySQL access, so there is no alternative route here.
Character set mismatch causes mojibake
This is the most common problem after a successful import. You see text like ’ where an apostrophe should be, or é instead of é. The data is not lost. The bytes are correct. The import just told MySQL to interpret them as the wrong character set.
The cause is almost always the same. Your old host exported the database as latin1 (the MySQL default for many years) and your new database is set to utf8mb4 (the modern default). MySQL stores the bytes, but when it reads them back it uses the wrong mapping.
The fix is to control both sides of the transfer.
- When you export from your old host, choose
utf8mb4as the export character set. Most phpMyAdmin installations have a dropdown for this on the Export tab. - When you import on CWP, make sure the new database and all its tables are also
utf8mb4. The database creation guide above covers this.
If you already imported with the wrong character set, drop the tables and re-import. Do not try to alter the character set after import — the data will still be wrong because the bytes were stored under the wrong encoding.
Large imports time out
phpMyAdmin runs PHP. PHP has a maximum execution time. On CWP free hosting that is 30 seconds. If your import takes longer than that, you will see the maximum execution time exceeded error.
The only workaround is to make the import faster. Compressing the file helps because the decompression is fast and the file is smaller. Splitting a large dump into smaller files also helps because each chunk finishes within the time limit. There is no setting you can change to extend the timeout.
After the import, update the config
The import puts the data into the database. Your application still points at the old database. Every CMS and framework has a configuration file with the database name, username, password, and host. On CWP free hosting the host is always localhost. Update that file with the new database credentials.
If you get the credentials wrong, the site will show the error establishing a database connection page. Double-check the database name and password in phpMyAdmin before you edit the config file.
Importing a database is not the hard part
The three clicks are trivial. The size limit and the character set are where people lose time. Compress the file, check the encoding, and update the config. That is the whole job.