How to Move a MySQL Database from Another Host to Your Account

Moving a website to us usually means moving two things: the files and the MySQL database behind them. This guide covers the database part -- how to export a MySQL database from your old host, create a matching database on your Instant Access Internet Services account, import it, and point your site at the new copy -- plus the errors people most often hit along the way.

If your site is WordPress, try WP Toolkit's import tool first: it copies the files and the database together and fixes the settings for you (see the related guides). Use this guide for other software, or when the automatic import doesn't work.

How a database move works

You can't copy a database like a folder. Instead you:

  1. Export it on the old host into a single .sql file (a long list of instructions that rebuild every table and row).
  2. Create an empty database and a database user here.
  3. Import the .sql file into the new, empty database.
  4. Update your website's config file with the new database name, username and password.

The names will almost certainly change. On our servers every database and database user starts with your cPanel username and an underscore -- shop on your old host becomes something like username_shop here. That's normal, and it's why step 4 matters.

Before you start

  • Keep the old site running until the new one is tested. Don't cancel your old hosting yet.
  • Pause changes on the old site. Orders, comments or form entries made after your export won't be in the copy. For a busy store, put the old site in maintenance mode just before you export.
  • Find the database details on the old host. They're in your site's config file: wp-config.php (WordPress), configuration.php (Joomla), .env (Laravel) or config.php for many others. Note the database name.
  • Check the size. phpMyAdmin here accepts import files up to 50 MB (compressed files count at their compressed size). If yours is bigger, use the SSH method in the related guides.

Step 1: Export the database from your old host

Option A: phpMyAdmin on the old host

  1. Log in to your old host's control panel and open phpMyAdmin.
  2. Click the database name in the left panel.
  3. Click the Export tab.
  4. Choose Custom. Under Output, set Compression to gzipped.
  5. Under Object creation options, make sure Add CREATE DATABASE / USE statement is not ticked. (If it is, the file tries to switch to the old database name and the import fails here.)
  6. Click Export. You'll get a file like shop.sql.gz.

Option B: the old host's cPanel backup page

If the old host also uses cPanel, Files > Backup there has a Download a MySQL Database Backup list. Click the database name to download a .sql.gz file. This works well for larger databases.

Option C: the command line on the old host

If you have SSH access on the old host, this is the most reliable export for big databases:

mysqldump --single-transaction --quick --no-tablespaces \
  -u olduser -p olddatabase | gzip > olddatabase.sql.gz

--single-transaction takes a consistent copy without locking the site, and --no-tablespaces avoids a "PROCESS privilege" error that newer MySQL versions give on shared hosting.

Whichever method you use, keep the downloaded file somewhere safe on your computer. It's your copy of the site's content.

Step 2: Create the new database and user here

  1. Log in to cPanel (from the client area: Services > My Services, choose your plan, then Log in to cPanel).
  2. Go to Databases > Database Wizard.
  3. Enter a database name (for example shop) and click Next Step.
  4. Enter a database username and a strong password, or use Password Generator. Copy the password somewhere safe, then click Create User.
  5. Tick ALL PRIVILEGES and click Next Step.

Write down the full names cPanel shows you, including the prefix -- for example username_shop and username_shopuser. You'll need all three values (name, user, password) in Step 4.

Step 3: Import the file

  1. In cPanel, go to Databases > phpMyAdmin.
  2. Click your new, empty database in the left panel. Its name should appear at the top of the page -- importing with no database selected is a common mistake.
  3. Click the Import tab.
  4. Click Browse (or Choose File) and pick your .sql or .sql.gz file.
  5. Leave the other settings alone and click Import.
  6. Wait for the green "Import has been successfully finished" message. The tables now appear in the left panel.

Quick check: click the Structure tab and compare the number of tables and approximate row counts with the old host. They should match.

Step 4: Point your website at the new database

Upload your website files (if you haven't already), then edit the config file here so it uses the new database.

For WordPress, open wp-config.php in Files > File Manager (right-click, Edit) and update these lines:

define( 'DB_NAME', 'username_shop' );
define( 'DB_USER', 'username_shopuser' );
define( 'DB_PASSWORD', 'the-password-you-copied' );
define( 'DB_HOST', 'localhost' );

Leave $table_prefix exactly as it was on the old host -- it has to match the table names you imported.

Other software uses the same four values under different names. For example, a Laravel .env file has DB_HOST=localhost, DB_DATABASE=, DB_USERNAME= and DB_PASSWORD=. The host is always localhost on our servers, because the database runs on the same server as your site.

Step 5: Test before you switch your domain

Until your domain's nameservers point to us, visitors still see the old site. That's a good thing -- it gives you time to check the new copy. Our nameserver guide (in the related links) explains the switch. After the change, check:

  • Pages and posts load, with the right content and images.
  • You can log in to the site's admin area.
  • Forms, search and checkout work.

If you had to pause the old site, remember that anything added there after your export (new orders, sign-ups) isn't in the new copy. Re-export and re-import just before you switch if needed.

Troubleshooting

"#1044 - Access denied for user ... to database 'olddatabase'"

The file contains a CREATE DATABASE or USE `olddatabase`; line. Open the file in a text editor (unzip it first if it's .gz), delete those lines near the top, save and import again. Or re-export with the Add CREATE DATABASE / USE statement option turned off.

"#1273 - Unknown collation: 'utf8mb4_0900_ai_ci'"

Your old host ran MySQL 8, which uses a collation name that MariaDB (what our servers run) doesn't recognize. Open the .sql file in a text editor that can handle large files, and use find and replace to change every utf8mb4_0900_ai_ci to utf8mb4_unicode_ci. Save and import into an empty database again.

"#1227 - Access denied; you need (at least one of) the SUPER privilege(s)"

The file contains DEFINER=`olduser`@`localhost` parts on views, triggers or procedures. Remove each DEFINER=... part (up to the next space) with find and replace, and import again.

"#1050 - Table ... already exists"

The database isn't empty -- often from a failed first attempt. In phpMyAdmin, open the database's Structure tab, tick Check all, choose Drop and confirm, then import again.

The file is larger than 50 MB

Compress it as .sql.gz first. If it's still too big, upload it and import over SSH -- see the guide on importing large databases in the related links -- or open a ticket and we'll help.

"Error establishing a database connection" after the move

The details in your config file don't match what's in cPanel. Double-check the full database name and username (with the prefix), make sure the user was added to the database with ALL PRIVILEGES, and set a fresh password if in doubt. Our database connection guide walks through it.

Strange characters (like é instead of é) after importing

The export and import used different character sets. Re-export from the old host with the character set set to utf8mb4 (or utf8) and import into a fresh, empty database. Don't try to fix the text by hand.

The site redirects to the old domain or a temporary address

The old address is stored in the database. For WordPress, see the search and replace guide in the related links.

Common questions

Can I keep the same database name as on my old host?

Only the part after the underscore. The username_ prefix is added automatically on our servers. Just update the config file to match.

Do I need to move the database users too?

No. Database users don't travel inside the .sql file. Create a new one here in Step 2.

Can you move it for me?

Yes. If you'd rather not do it yourself, open a ticket with the old host's details or upload the .sql file to your account and tell us where it is.

Related guides

Still stuck? Open a support ticket and the Instant Access Internet Services team will help.

Ultrafast LiteSpeed hosting from InstantAccess.net: free SSL, free backups, cPanel included, no contracts. Check out our $10/month hosting.
  • move mysql database to new host, migrate database cpanel, transfer mysql database, export database from old host, import database new host, unknown collation utf8mb4_0900_ai_ci, migrate website database
  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

How to Change a MySQL Database User's Password

You might need to change a database password after a security scare, when a developer leaves, or...

How to Create a MySQL Database and User in cPanel

Most website software, including WordPress, Joomla and online shops, stores its content in a...

How to Import and Export a Database with phpMyAdmin

phpMyAdmin lets you save a copy of a database to your computer or load a database from a file,...

How to Open phpMyAdmin from cPanel and Find Your Way Around

phpMyAdmin is a web page for looking inside your MySQL databases: you can see the tables your...

How to Import a Database That's Too Big for phpMyAdmin (Using SSH)

phpMyAdmin on your hosting account accepts import files up to 50 MB, and even smaller files can...