LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 11-29-2010, 07:29 AM   #1
d-niX
LQ Newbie
 
Registered: Nov 2010
Distribution: Ubuntu , Debian
Posts: 11

Rep: Reputation: 0
migrating MySql DB from version 4.0 to version 5.1


Hello,

I want to upgrade mediawiki software from version 1.6 to version 1.16 .
The newer version is supposed to be installed on another server.
I am trying to migrate the old mediawiki mysql database with no success.



I run the following commands -

##on new server##

Code:
create database <new-db>;

grant index, drop, create, select, insert, update, delete, alter, lock tables on <new-db>.* to '<new-user>'@'localhost' identified by '<password>';
##on old server##

Code:
mysqldump -h loaclhost -u <old-user> -p <old-db> > dump_file

to restore db on new server -


Code:
mysql -h localhost -u <new-user> -p <new-db> < dump_file

I get the following error message -

Code:
ERROR 1062 (23000) at line <line-number>: Duplicate entry '<some-text>' for key '2'
I tried solving the problem with not much success.

I will appreciate your help.
 
Old 11-29-2010, 07:42 AM   #2
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 27,713

Rep: Reputation: 8168Reputation: 8168Reputation: 8168Reputation: 8168Reputation: 8168Reputation: 8168Reputation: 8168Reputation: 8168Reputation: 8168Reputation: 8168Reputation: 8168
Quote:
Originally Posted by d-niX View Post
Hello,
I want to upgrade mediawiki software from version 1.6 to version 1.16 .
The newer version is supposed to be installed on another server.
I am trying to migrate the old mediawiki mysql database with no success.

I run the following commands -
##on new server##
Code:
create database <new-db>;
grant index, drop, create, select, insert, update, delete, alter, lock tables on <new-db>.* to '<new-user>'@'localhost' identified by '<password>';
##on old server##
Code:
mysqldump -h loaclhost -u <old-user> -p <old-db> > dump_file
to restore db on new server -
Code:
mysql -h localhost -u <new-user> -p <new-db> < dump_file
I get the following error message -
Code:
ERROR 1062 (23000) at line <line-number>: Duplicate entry '<some-text>' for key '2'
I tried solving the problem with not much success. I will appreciate your help.
Well, the error is pretty clear. You've got a duplicate key in your data. So, you can either modify the data, or modify the structure.

In this case, though, I'd omit the "grant index" step until after you've imported your data. Just create the blank database, and use root to do the import, and see what happens.
 
Old 11-29-2010, 09:13 AM   #3
d-niX
LQ Newbie
 
Registered: Nov 2010
Distribution: Ubuntu , Debian
Posts: 11

Original Poster
Rep: Reputation: 0
.

Quote:
Originally Posted by TB0ne View Post
Well, the error is pretty clear. You've got a duplicate key in your data. So, you can either modify
the data, or modify the structure.

In this case, though, I'd omit the "grant index" step until after you've imported your data. Just create the blank database, and use root to do the import, and see what happens.
I don't have duplicate key in my date. the old mediawiki db is up and running just fine. I can't have a duplicate primary key since the RDBMS will not allow it . I went over the script in the dump file and i saw that in the line that causing the problem there is an INSERT statement to a table called "mywikipage" and when i comment this line the migration went well but still.... it does not solve the problem.
 
Old 11-29-2010, 09:35 AM   #4
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 27,713

Rep: Reputation: 8168Reputation: 8168Reputation: 8168Reputation: 8168Reputation: 8168Reputation: 8168Reputation: 8168Reputation: 8168Reputation: 8168Reputation: 8168Reputation: 8168
Quote:
Originally Posted by d-niX View Post
I don't have duplicate key in my date. the old mediawiki db is up and running just fine. I can't have a duplicate primary key since the RDBMS will not allow it . I went over the script in the dump file and i saw that in the line that causing the problem there is an INSERT statement to a table called "mywikipage" and when i comment this line the migration went well but still.... it does not solve the problem.
You don't have a duplicate key? You posted this:
Quote:
Originally Posted by d-niX
ERROR 1062 (23000) at line <line-number>: Duplicate entry '<some-text>' for key '2'
And you say when you comment out the INSERT (that's trying to put the duplicate key in), it works. Error 1062, from the MySQL site, defines it as a duplicate key problem. From the MySQL reference manual, along with a possible solution:
http://dev.mysql.com/doc/refman/5.5/...rt-select.html

Search for "1062" in that link.
 
Old 11-30-2010, 06:22 AM   #5
d-niX
LQ Newbie
 
Registered: Nov 2010
Distribution: Ubuntu , Debian
Posts: 11

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by TB0ne View Post
You don't have a duplicate key? You posted this:

And you say when you comment out the INSERT (that's trying to put the duplicate key in), it works. Error 1062, from the MySQL site, defines it as a duplicate key problem. From the MySQL reference manual, along with a possible solution:
http://dev.mysql.com/doc/refman/5.5/...rt-select.html

Search for "1062" in that link.
Thank you.

In order to solve this problem i commented a "unique" constraint in the structure definition of the "problematic" table appearing in the script "mysqldump" generated and by that i was able to restore the DB . Now i just have to add this unique constraint to the DB...
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
cannot open mysql gui on mysql version 6.0 vitalstrike82 Slackware 6 05-30-2009 11:37 PM
Regarding distribution + kernel version + gcc version + glib version. JCipriani Linux - General 8 04-19-2008 02:54 PM
can't make mysql command run the right mysql version crimson.dynamo Linux - Newbie 9 06-20-2007 09:36 AM
migrating accounts from maching and distribution version linuxnube Linux - General 2 03-08-2005 06:53 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 01:14 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration