Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > PHP/MySQL > Beginning PHP
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Beginning PHP Beginning-level PHP discussions. More advanced coders should post to the Pro PHP forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning PHP section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old December 15th, 2003, 10:55 PM
Registered User
 
Join Date: Nov 2003
Location: , , New Zealand.
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to mespejo Send a message via Yahoo to mespejo
Default Populating database tables

Hi

Can anyone please tell me how to populate a table in mysql from an external file (i.e. pop_table.sql which I downloaded from this site)?

In reference to Chapter 11, page 420

Reply With Quote
  #2 (permalink)  
Old December 16th, 2003, 01:42 AM
Authorized User
 
Join Date: Jun 2003
Location: San Jose, CA, USA.
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
Default

the first suggestion is:

http://www.phpmyadmin.net/home_page/

Go get this program...

I don't recall the actual command to do the manual install because I always use this program.. Great for managing MySQL!

Good luck.

----------
~cmiller
Reply With Quote
  #3 (permalink)  
Old December 16th, 2003, 02:51 AM
Registered User
 
Join Date: Nov 2003
Location: , , New Zealand.
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to mespejo Send a message via Yahoo to mespejo
Default

Hey, thanks a lot!

Cheers:)

Reply With Quote
  #4 (permalink)  
Old December 16th, 2003, 02:54 AM
richard.york's Avatar
Wrox Author
Points: 5,506, Level: 31
Points: 5,506, Level: 31 Points: 5,506, Level: 31 Points: 5,506, Level: 31
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Camby, IN, USA.
Posts: 1,706
Thanks: 0
Thanked 6 Times in 6 Posts
Default

phpmyadmin makes things pretty easy if you want a PHP-based solution. However if you are looking for a command line solution to work directly with the MySQL server you could read the MySQL manual entry for the mysqldump utility which shows the syntax for importing SQL from an external file.

Quote:
quote:From: http://www.mysql.com/doc/en/mysqldump.html

The most normal use of mysqldump is probably for making a backup of whole databases. See section 4.5.1 Database Backups.

mysqldump --opt database > backup-file.sql
You can read this back into MySQL with:

mysql database < backup-file.sql
or

mysql -e "source /path-to-backup/backup-file.sql" database
hth,
: )
Rich



:::::::::::::::::::::::::::::::::
Smiling Souls
http://www.smilingsouls.net
:::::::::::::::::::::::::::::::::
Reply With Quote
  #5 (permalink)  
Old December 16th, 2003, 03:29 AM
Registered User
 
Join Date: Nov 2003
Location: , , New Zealand.
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to mespejo Send a message via Yahoo to mespejo
Default

Hi Rich

This is exactly what I am looking for...

Thanks for your input.

Cheers:)
Cel

Reply With Quote
  #6 (permalink)  
Old December 16th, 2003, 04:08 AM
Registered User
 
Join Date: Nov 2003
Location: , , New Zealand.
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to mespejo Send a message via Yahoo to mespejo
Default

Hi Rich

Pardon me for being obtuse but this is in reference again with Chapter 11, page 420. I'm having trouble understanding the manual you have stated above.

I have a database called sample_db with 2 tables in it namely access_log and user. Since these tables needed to be populated, I don't want to type all these data by hand so I am looking for a way on how to copy the SQL codes necessary to populate these tables from an external file called pop_table.sql

Can you pls. show me how to use the correct syntax for importing SQL from this external file?


Reply With Quote
  #7 (permalink)  
Old December 16th, 2003, 12:28 PM
Friend of Wrox
Points: 2,570, Level: 21
Points: 2,570, Level: 21 Points: 2,570, Level: 21 Points: 2,570, Level: 21
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: San Diego, CA, USA
Posts: 836
Thanks: 0
Thanked 0 Times in 0 Posts
Default


cat your_dump_file | /path/to/mysql/bin/mysql -uusername -ppassword databasename



Take care,

Nik
http://www.bigaction.org/
Reply With Quote
  #8 (permalink)  
Old December 16th, 2003, 03:53 PM
Registered User
 
Join Date: Nov 2003
Location: , , New Zealand.
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to mespejo Send a message via Yahoo to mespejo
Default

Thanks Nik! Problem solved...

Cheers
Cel

Reply With Quote
  #9 (permalink)  
Old December 17th, 2003, 04:53 PM
Friend of Wrox
Points: 2,570, Level: 21
Points: 2,570, Level: 21 Points: 2,570, Level: 21 Points: 2,570, Level: 21
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: San Diego, CA, USA
Posts: 836
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Another tip: You can use mysqldump to dump the contents of one database directly into another, even if the databases are located on different hosts:

mysqldump -uuser -ppass -hhostname -q database | mysqldump -uuser -ppass -hhostname database


The -q option to mysqldump means that it doesn't buffer the output until it's all done to display it. Without that flag, mysqldump will create a huge string containing all the dump strings, and then output that string all at once.

With large dumps, it's much quicker to just dump output as it's generated, instead of buffering it all. That way, mysql can start creating the other database as it recieves dump output, instead of waiting for mysqldump to completely finish first.



Take care,

Nik
http://www.bigaction.org/
Reply With Quote
  #10 (permalink)  
Old November 30th, 2004, 11:02 AM
Registered User
 
Join Date: Nov 2004
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi

Is it posible to copy data from -tables- between two databases


Andrew
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Populating TreeView Control using Access Database dotnetDeveloper ADO.NET 0 November 18th, 2008 12:58 PM
Populating One Database to Another Brendan Bartley Access 1 March 12th, 2008 06:39 AM
Populating a multiple select box from a database ozzii Classic ASP Databases 0 February 15th, 2007 06:40 AM
how to get all the tables from a database rakeshgv SQL Server 2000 4 December 1st, 2006 08:33 AM
Creating & Populating Tables jitu ADO.NET 11 June 3rd, 2004 01:04 PM



All times are GMT -4. The time now is 04:14 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.