PDA

View Full Version : Exporting/Importing table from MySQL with help of PHP files.


wooolF[RM]
03-17-2002, 01:47 PM
]Hello all :)

Well... First want to say many thanx to FireFly for all help he have provided and for all his answers :)

I got a lil problem here. I must export table "templates" from MySQL database on the server where I have not installed myadmin yet and I don't have telnet access to it. So I must use PHP files to connect to the database and dump only one table from there (I'll download it after from FTP).

After that I must import it in another database. Just override old table. I don't know if I need to drop it first or I can just override it. I can use telnet/ftp/myadmin there with that MySQL database. So I will be very appreciated if u could paste the string I have to run to get that dumped table imported.

As u see I need to export a table with help of PHP file and then import that dumped table with help of telnet/myadmin/PHP file.

Please help if u can.

Thanx very much :)

wooolF[RM]
03-17-2002, 02:06 PM
]
<?
mysql_connect("host","login","pass");
$query = "DUMP TABLE template FROM DATABASE databasenamehere";
$result = mysql_query($query);
?>

??? like that ???

wooolF[RM]
03-17-2002, 03:38 PM
wroooooooooooom

wooolF[RM]
03-18-2002, 11:40 AM
]really no one? :(

wooolF[RM]
03-19-2002, 08:52 AM
]can something like this do the job:


<?
system ("mysqldump -u from_username_from -pfrom_password -h from_host
from_db from_table | mysql -u to_user -pto_pass -h to_host to_db_name");
?>


Meaning of it is if I wish to copy the table to a completely different server.

nsr81
03-19-2002, 10:31 AM
Hi there Woolf,

If it is a one time thing then I'd use phpMyAdmin to dump the table/db and get an sql script which you can run on your second server. If not, may be some one else can offer an opinion :)

wooolF[RM]
03-19-2002, 10:38 AM
]well.. I have dumped table allready from one server... now I just need to be sure that commands I gave before are right ones :)

wooolF[RM]
03-19-2002, 01:22 PM
thanx for help support... sorted it out myself...