Best way to import a MySQL Dump file

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

I'd suggest looking through raghavan20's posts in regex/databases .. I remember several threads on extracting the individual queries in a dump file for insertion that I was involved in. They might be linked from Useful Posts, but I can't recall that specificly.
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

I'm telling ya, the phpBB install script is worth a look. It is really easy to see what is going on and just about as easy to implement.

Files to look at...

/includes/sql_parse.php
/install/install.php
/install/schemas/mysql_basic.sql
/install/schemas/mysql_schema.sql
User avatar
dibyendrah
Forum Contributor
Posts: 491
Joined: Wed Oct 19, 2005 5:14 am
Location: Nepal
Contact:

Post by dibyendrah »

The best and easy way to read the mysql dump is with phpmyadmin from control panel of the website. Otherwise you should tell the hosting company to enable execution of binaries for limited programs ...

Cheers,
Dibyendra
AlexC
Forum Commoner
Posts: 83
Joined: Mon May 22, 2006 10:03 am

Post by AlexC »

AlexC_ do you have control of install/stage3/tables.sql, if you do why not change it to install/stage3/table.sql.php and put each separate query as a separate element of an array?
Of course I do, It's my CMS I'm coding! hehe- that's not a bad idea actaully and it would be better than XML
What do you mean with 'XML would be the best way'? And what would be the dtd/xsd of the xml file?
I was thinking of putting each query in the XML document then parsing it and running each query - might not be a good idea actaully
How about looking at phpBB's installation code then. phpMyAdmin is a bit rough, but phpBB code might be a little easier to read through.
I'll have a look at that, thanks
AlexC
Forum Commoner
Posts: 83
Joined: Mon May 22, 2006 10:03 am

Post by AlexC »

dibyendrah, I can't do that - My CMS install needs to "Just work" without the Average Joe contacting his hosting company to enable something.
User avatar
Ollie Saunders
DevNet Master
Posts: 3179
Joined: Tue May 24, 2005 6:01 pm
Location: UK

Post by Ollie Saunders »

Of course I do, It's my CMS I'm coding! hehe- that's not a bad idea actaully and it would be better than XML
There's your solution then.
AlexC
Forum Commoner
Posts: 83
Joined: Mon May 22, 2006 10:03 am

Post by AlexC »

Well I've been looking through the phpBB source code and I can actually understand it! I'm going to implement it into my Install now :P
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

Good job Alex. Let us know if things go wonky.
AlexC
Forum Commoner
Posts: 83
Joined: Mon May 22, 2006 10:03 am

Post by AlexC »

Yep, it works and it works well!

Thanks a lot everyone for your help :wink:
Post Reply