FYI: mySQL export/import

Discuss phpwcms here, please do not post support requests, bug reports, or feature requests! Non-phpwcms questions, discussion goes in General Chat!
Post Reply
User avatar
pSouper
Posts: 1552
Joined: Tue 11. Nov 2003, 15:45
Location: London
Contact:

FYI: mySQL export/import

Post by pSouper »

Hi All,
I have just had to export my database from remote server and imported it to my localhost. I was getting an SQL error that meant I could NOT import the database :(

The reason for the error was that the table 'phpwcms_articlecontent' was just to darn big. mySQL has a 1mb default on it's 'max_allowed_packet' or to us simple folk maximum individual 'query' size. As your site grows (and it will :lol: ) you to will have this problem if you should ever need to import a backup of your databes too.
There are a number of fixes if you have control over my.ini but if not a quick hack to your .sql will be equally good...
isolate the table 'phpwcms_articlecontent' then perform a search & replace...
Find: ),

Replace with: ); INSERT INTO `phpwcms_articlecontent` VALUES
This effectivly breaks your single large query into tiny manageble sizes.

I hope you never have to use it but if you do I hope it helps ;)
Last edited by pSouper on Fri 4. Jun 2004, 15:12, edited 1 time in total.
frold
Posts: 2151
Joined: Tue 25. Nov 2003, 22:42

Post by frold »

I have this little cool tool I use when I need to upload huge databases,,


The program is 24kb and let you chunks a database in to peaces of 250kb...

If you database is 1mb you will have 4 files that is 250kb big and named 1,2,3,4...

Very fancy little tool...

I will share it with you :D

http://www.frold.dk/filer/MakeChunks.zip
http://www.studmed.dk Portal for doctors and medical students in Denmark
User avatar
pSouper
Posts: 1552
Joined: Tue 11. Nov 2003, 15:45
Location: London
Contact:

Post by pSouper »

Mmm that app is as smooth as a babies bottom (trust me, i know)
SNap
Posts: 314
Joined: Wed 5. May 2004, 10:45
Location: Passau, Bavaria, Germany
Contact:

Post by SNap »

hmmm strange, on my Forum my Database is about 60MB big, and i have no Problem reimporting it on my local site.

how did you backup? mith 'mysqldump' ?
'welcome to the real world!' datensysteme-lenk
Pappnase

Post by Pappnase »

hello snap

look at this link! maybe you use mysql front?

http://www.script-test.de
SNap
Posts: 314
Joined: Wed 5. May 2004, 10:45
Location: Passau, Bavaria, Germany
Contact:

Post by SNap »

nope i use commandline 'mysql < dumpfile' (not correct syntax!)
'welcome to the real world!' datensysteme-lenk
User avatar
pSouper
Posts: 1552
Joined: Tue 11. Nov 2003, 15:45
Location: London
Contact:

Post by pSouper »

I had just used 'Export' form phpMyAdmin.
then loaded the file back in via the SQL query (file browse).
By default Max_Allowed_Packet = 1MB but I was unable to affect a change for some reason.
I have strange things affot with my mySQL installation... my.ini is show as per the file within my 'winMySQLadmin' BUT the opertation is not as stated regarding passwords or set_variables.

but it works so I'm NOT touching it :)
SNap
Posts: 314
Joined: Wed 5. May 2004, 10:45
Location: Passau, Bavaria, Germany
Contact:

Post by SNap »

you shouldn't use phpmyadmin for such big backup/restore actions! to slow anyway ;)

do it with mysqldump and mysql < dumpfile. much faster and reliable ;)
'welcome to the real world!' datensysteme-lenk
frold
Posts: 2151
Joined: Tue 25. Nov 2003, 22:42

Post by frold »

SNap wrote: do it with mysqldump and mysql < dumpfile. much faster and reliable ;)
What is that?
http://www.studmed.dk Portal for doctors and medical students in Denmark
User avatar
pSouper
Posts: 1552
Joined: Tue 11. Nov 2003, 15:45
Location: London
Contact:

Post by pSouper »

;) thanks.

of course I live an a small world that worship the god of 'crap' we bury our heads in the mud and show our bottoms to the sky religiously once every lunar month. Our entire belief system revolves around the premise that by sacrificing our databases to him (or her) on a regular basis at great time and cost (the more the better) he (or she) will not shower us in sh*t for another four weeks.
in short: if it is too quick and easy for us to backup & restor the sacrifice will not be so effective ;)
SNap
Posts: 314
Joined: Wed 5. May 2004, 10:45
Location: Passau, Bavaria, Germany
Contact:

Post by SNap »

frold wrote:
What is that?
What is what?

make a backup with my script http://www.phpwcms.de/forum/viewtopic.php?t=2166

and restore with

Code: Select all

mysql -h host -u user -p password database < ./dumpfile
did you mean that?
'welcome to the real world!' datensysteme-lenk
Post Reply