Link to home
Start Free TrialLog in
Avatar of Sumukha
Sumukha

asked on

Import MySql WorPress data base creates error

I usually build Wordpress sites on a server with a different domain than the final destination.
I then export the db in phpMyAdmin, replace the site url, and import into the phpMyAdmin of the final server and domain.
Usually no problem, done it xx times.

Now suddenly I am running into errors either of
"Access denied for user 'xxxxxx'@'localhost'
(that is on the destination server)
or
on the original server where I want to duplicate the db
#1007 - Can't create database 'xxxxx_yyyyy'; database exists

Regarding the original server with the #1007 error:
I see in the sql dump in line 19 and below:

--
-- Database: `xxxxx_yyyyy`
--
CREATE DATABASE `xxxxx_yyyyy` DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;
USE `xxxxx_yyyyy`;

I tried replacing that with the name of the empty database in which I want to import, but get the same error.

Hope this makes sense to someone out there.

Please consider in your suggestions that I do not use command-line tools.

Thanks!
Avatar of Tom Beck
Tom Beck
Flag of United States of America image

The way I've done it successfully in the past avoids creating the database through phpMyAdmin.  Instead, I let Wordpress create the database and tables and just import the data. That way the permissions are no longer an issue.

- From the Export tab for the database in question in phpMyAdmin, choose Custom - display all possible options.
- Select the table you want or select all.
- View as text.
- Format: SQL
- I usually uncheck "Display comments...". It clutters up the file unnecessarily.
- Under "Dump Table" choose "data". You only want the data, not the structure.
- Under Data Dump Options leave the defaults.
- Click Go

Copy the resulting SQL statements to your clipboard and paste them into a SQL query window of phpMyAdmin on the destination server and execute.
Avatar of Sumukha
Sumukha

ASKER

Thanks for posting tommyboy,

How would you duplicate a database then?
It sounds like the destination server does not allow CREATE DATABASE to be executed by your user account.  I see this at shared hosting ISPs a lot, security measure of sorts.

Simply create the database according to the instructions provided by the ISP (usually "do it via CPanel") and remove the line from the SQL dump.  If this is a server fully under your control, you will need to check the permissions for that user account.
Probably the way you have attempted, by checking the proper boxes in phpMyAdmin to create the database and tables along with the data. But we are talking about Wordpress here. It's been in development for a long time and no doubt has it's own unique requirements for privileges. Any difference in WP versions between the testing server and the live on could spell trouble. Why risk it? Besides, you always want to have a contingency plan for rebuilding a Wordpress site from scratch. Including rebuilding the databases. Wordpress sites can get corrupted by plugins. Back to your situation, even if the table names were different on my destination server, I would only transfer the data and let Wordpress create the database and tables. In that scenario I would instead save the SQL statements generated by the export to a file, open it in a text editor, find and replace the table names, then execute the statements on the destination server's empty tables. I would not attempt to create the entire structure that way. I'm a web developer, not a database expert, so that's my inclination. Maybe a database expert will post with a different idea.
no doubt has it's own unique requirements for privileges

Nope.  If anything, it's the opposite since WP has to be able to run on nearly any deployment.  WordPress has nothing to do with setting database permissions and issues with plugins result in the site getting hacked and defaced, not database corruption.
Okay Jason, I'll buy that. Do you see anything wrong with my approach though? Have I been doing it wrong all this time? It always works.
ASKER CERTIFIED SOLUTION
Avatar of Sumukha
Sumukha

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
CREATE DATABASE `xxxxx_yyyyy` DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;
USE `xxxxx_yyyyy`;

Open in new window


This is all one command (two technically) that doesn't need to be there if the database is already created and selected in phpMyAdmin.
Now imagine this:
I am now doing the EXACT same steps from another computer and it works.

Wonderful.  Don't argue with your good fortune?
Avatar of Sumukha

ASKER

I always want to know WHY things happen.
I have no idea why the same thing works differently on different boxes :/

The only thing I can think of is that you did change something between attempts...that's the only thing that makes sense.
Avatar of Sumukha

ASKER

Nothing. Njente.

Errors for duplicating the oiginal db (export/ import into empty one), as well as import on the other server into an empty one.
Avatar of Sumukha

ASKER

Now who gets points?
Avatar of Sumukha

ASKER

Thanks, Jason. Will do.

Here is something else for you to peek at:
http://www.experts-exchange.com/Web_Development/Miscellaneous/Q_28325248.html
Avatar of Sumukha

ASKER

It works on a different machine and nobody knows why...