Solved

Import MySql WorPress data base creates error

Posted on 2013-12-15
17
469 Views
Last Modified: 2013-12-29
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!
0
Comment
Question by:Sumukha
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 6
  • 3
17 Comments
 
LVL 38

Expert Comment

by:Tom Beck
ID: 39721283
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.
0
 

Author Comment

by:Sumukha
ID: 39721440
Thanks for posting tommyboy,

How would you duplicate a database then?
0
 
LVL 70

Expert Comment

by:Jason C. Levine
ID: 39721639
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.
0
Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

 
LVL 38

Expert Comment

by:Tom Beck
ID: 39721661
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.
0
 
LVL 70

Expert Comment

by:Jason C. Levine
ID: 39721691
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.
0
 
LVL 38

Expert Comment

by:Tom Beck
ID: 39721767
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.
0
 

Accepted Solution

by:
Sumukha earned 0 total points
ID: 39722054
Thanks for posting, guys (and hi there Jason),

Now imagine this:
I am now doing the EXACT same steps from another computer and it works.

@ Jason "and remove the line from the SQL dump"

I posted four lines. Which one you are referring to?

Thanx
0
 
LVL 70

Expert Comment

by:Jason C. Levine
ID: 39722100
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.
0
 
LVL 70

Expert Comment

by:Jason C. Levine
ID: 39722104
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?
0
 

Author Comment

by:Sumukha
ID: 39722124
I always want to know WHY things happen.
0
 
LVL 70

Expert Comment

by:Jason C. Levine
ID: 39722134
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.
0
 

Author Comment

by:Sumukha
ID: 39722709
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.
0
 

Author Comment

by:Sumukha
ID: 39738421
Now who gets points?
0
 
LVL 70

Expert Comment

by:Jason C. Levine
ID: 39738424
0
 

Author Comment

by:Sumukha
ID: 39738461
Thanks, Jason. Will do.

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

Author Closing Comment

by:Sumukha
ID: 39744508
It works on a different machine and nobody knows why...
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

An enjoyable and seamless user experience can go a long way on an eCommerce site. While a cohesive layout and engaging copy play roles in creating a positive user experience, some sites neglect aspects that seem marginal but in actuality prove very …
When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question