PDA

View Full Version : Dump a single table


Martz
Sat 2nd Jun '01, 9:16pm
I am trying to introduce some sort of replication between 2 sites to sync usernames and passwords, the host being vB. So far we have added extra code to do the inserts for registration and profile editing on the remote server as well as locally, and that part is working well - we are duplicating our data on the fly. However, we will also want to schedule a cron job on the local server to dump just the user table to allow it to be ftp'ed over to the remote server, and inserted.

It needs to be automated so just selecting the user field in the admin backup option isn't enough - how would I dump a single table from mysql? Can I use:
mysql -u username -p > usernameonly.sql myvbtablename.user

Is this feasible?
Am I using the correct syntax
Am I approching this problem from the right angle

My host doesn't allow remote access of the mySQL tables, but the remote host has full control over his dedicated server.
Any pointers or ideas very much welcome and appreciated :)

tubedogg
Sun 3rd Jun '01, 2:42pm
mysql -uUSERNAME -pPASSWORD dbname vbtablename > /path/to/file.sql

Martz
Sun 3rd Jun '01, 2:54pm
That seems to be incorrect syntax - It outputs the mysql helpfile. If I dont define the table it works fine - I can't output the table directly. :(

tubedogg
Sun 3rd Jun '01, 3:08pm
mmm whoops

Try

mysqldump -uUSERNAME -pPASSWORD dbname vbtablename > /path/to/file.sql

And if that doesn't work, try

mysqldump -uUSERNAME -pPASSWORD dbname --tables vbtablename > /path/to/file.sql

Martz
Sun 3rd Jun '01, 3:11pm
Thanks, I just worked that one out :) Help appreciated.