Fixing “Can't connect to MySQL server” after a WordPress import
Your zip's wp-config.php still points at your old host's local database (127.0.0.1). Re-run the import with a database that exists on Anested and the error goes away.
What the error means
A WordPress site is two things: files and a database. The zip you upload carries the files — and a wp-config.php that describes where the database used to be. That location almost never survives a move.
I imported my site and got 'ERROR 2002: Can't connect to MySQL server' or 'Error establishing a database connection'. What happened?
Open the wp-config.php that came inside your zip and look at the database block. On most shared hosts (Hostinger, GoDaddy, Bluehost…) it looks like this:
DB_HOST is 127.0.0.1 (or localhost). That means “the MySQL server running on this same machine”. On your old host that was true. On Anested's web servers there is no MySQL running locally — databases live on dedicated database servers — so every connection attempt to 127.0.0.1 fails instantly.
The database name and user (u554126354_…) are also internal to your old host. Even if you knew its real hostname, shared hosts don't allow connections from outside, so those credentials can't be reused.
define( 'DB_NAME', 'u554126354_w4usu' );
define( 'DB_USER', 'u554126354_vLr7r' );
define( 'DB_PASSWORD', '••••••••••' );
define( 'DB_HOST', '127.0.0.1' ); // ← the old host's local MySQLI uploaded a new .sql dump — why didn't that fix it?
Because the dump and wp-config.php are different things. The .sql file is your data (posts, pages, settings, users). wp-config.php is the connection — which server to talk to and with which password.
Importing a dump pushes data into whatever database wp-config.php points at. If that is a dead 127.0.0.1, the import can't even start. Uploading a bigger, newer or different dump changes nothing about where WordPress is trying to connect.
Does Anested rewrite wp-config.php automatically?
Only when you ask it to. The WordPress import has four database modes:
- Auto-create a database — Anested provisions a managed MySQL database and writes a fresh wp-config.php pointing at it. This is the mode you want after moving from another host.
- Use my own database — you paste host, name, user and password of a MySQL database you already created (in your Anested Databases section or anywhere reachable on the internet). A fresh wp-config.php is written with those details.
- Keep current database — reuses the wp-config.php already on the server. Correct for a second run once the connection works (e.g. to import a newer dump or fix URLs). Wrong if the file still says 127.0.0.1.
- Skip — my files handle it — leaves whatever wp-config.php came in the zip untouched. Use this only if your zip's config already points at a reachable remote database.
Fixing it
Do I need to create a database for this site?
Yes — a database has to exist somewhere Anested can reach. The one from your old host is gone as far as your new site is concerned. You have two easy options, both inside the site's Overview tab under “Update import”:
- Pick “Auto-create a database”, attach your .sql dump (if you haven't imported it yet), enter your old site URL, and click “Re-run import”. Anested creates a managed MySQL database from your hosting plan, writes wp-config.php for it, imports the dump and rewrites your old URL to the new one.
- Or create the database yourself first: open the site's Databases tab (or Databases → MySQL), click “Create database”, then copy its host, database name, user and password into “Use my own database” on the re-run form.
Step by step: re-running the import with a working database
From your Anested dashboard:
- Open the site → Overview tab. Under the WordPress card, find “Update import”.
- Choose “Auto-create a database” (or “Use my own database” and fill the four fields).
- SQL dump: attach your .sql export if the database is still empty. If you already imported it successfully earlier, leave this blank.
- Old site URL: type your previous address (https://example.com). Leave it empty if you don't know it — Anested detects it from the imported data.
- Click “Re-run import”. The site is reachable at its .web.anested.com address within a minute; log in at /wp-admin with your old WordPress credentials.
Can I just edit wp-config.php myself instead?
Yes. Create a database in the Databases tab, then open Files → public → wp-config.php in the file editor and replace DB_NAME, DB_USER, DB_PASSWORD and DB_HOST with the new values (the host includes the port, e.g. mysql.anested.com:3306). Save, then go back to Overview → Update import, keep “Keep current database” selected, attach your .sql dump and re-run so the data gets imported.
Re-running the import with new details is simply the same edit done for you, plus the dump import and URL fix in one go.
Does the hosting database cost extra?
No. Managed MySQL databases are included with every hosting plan. Each one reserves 1 GB of your account's shared storage pool (files, backups and databases share that pool); its real size only counts once it grows past 1 GB. You can create as many as the pool can hold.
Still broken?
The import now says 'Can't connect to the database in wp-config.php (host …)' with a different host
Anested tested the connection before importing and it failed. If you used “Use my own database”, double-check each field — hostname with port, database name, user and password are all case-sensitive — and make sure the remote server allows connections from outside (many shared hosts don't). If you created the database on Anested, copy the values again from the Databases tab; the password is shown with the “show” button.
The site loads but shows the WordPress install screen or is empty
The connection works but the database has no data — the .sql dump was never imported. Go to Overview → Update import, choose “Keep current database”, attach your .sql file and re-run. Don't complete the install screen: that would create a blank site in the same database.
The site redirects to my old domain or images are missing
That is the URL-fix step, not the database. See the migration guide — re-run the import with your old site URL filled in, or leave it blank so Anested detects it from the database.
Still stuck?
Our team can look at your site directly — reach out and we'll help you sort it.