Page 1 of 1
mysql, code to extract all content
Posted: Sat Aug 06, 2005 6:28 am
by orangeapple
Hi,
I'm looking for the mysql code to extract all datae (content only) from all tables.
Does someone know that code ?
Thanks a lot.
Posted: Sat Aug 06, 2005 6:52 am
by anjanesh
Extract or Export ?
phpmyadmin
Posted: Sat Aug 06, 2005 8:01 am
by feyd
Posted: Mon Aug 08, 2005 12:32 pm
by orangeapple
well... i just would like to :
1. get the code of what is done when you export all datae (only datae, but from all tables of the database) in phpmyadmin.
2. Then, i suppose i can create a .sql file with 'fopen' and 'fclose' ?
Is that the proper way to do it ? any other suggestions ?
Posted: Mon Aug 08, 2005 1:12 pm
by feyd
read my posted link.
Posted: Tue Aug 09, 2005 12:25 am
by orangeapple
what is wrong with this ?:
SELECT * INTO OUTFILE 'c:/backup.sql' FROM microsedb;
this is the error message :
Parse error: parse error in c:\program files\easyphp1-8\www\microsent\pages\backup_answer.php on line 137
Posted: Tue Aug 09, 2005 12:33 am
by nielsene
perhaps you're wrapping the query in single quotes so the single quoates around the filename drop you out of the string?
Posted: Tue Aug 09, 2005 12:52 am
by orangeapple
same error message for :
SELECT * INTO OUTFILE "c:/backup.sql" FROM microsedb;
Posted: Tue Aug 09, 2005 8:14 am
by feyd
if you placed that into the code without sending it to mysql through mysql_query() (and not inside a string correctly) you may have issues.. Is that the line in its entirety?
Posted: Sun Aug 14, 2005 12:27 pm
by orangeapple
Ok, now I can create a backup file with the following script :
$sql_query = "SELECT * INTO OUTFILE 'c:/backup.sql' FROM login";
$result_sql_query = mysql_query($sql_query);
the result in the outfile is the following :
1 admin1 Fri 26th Mar 2004 06:56 pm Mon 10th May 2004 08:52 pm 1080323790
2 admin1 Tue 30th Mar 2004 07:48 pm Mon 10th May 2004 08:52 pm 1080668898
3 admin1 Tue 30th Mar 2004 08:48 pm Mon 10th May 2004 08:52 pm 1080672515
4 admin1 Mon 05th Apr 2004 08:48 pm Mon 10th May 2004 08:52 pm 1081190916
5 admin1 Mon 05th Apr 2004 08:59 pm Mon 10th May 2004 08:52 pm 1081191554
6 admin1 Mon 05th Apr 2004 09:09 pm Mon 10th May 2004 08:52 pm 1081192181
7 admin1 Mon 05th Apr 2004 09:10 pm Mon 10th May 2004 08:52 pm 1081192215
but this file is not usable for reloading as it should be :
INSERT INTO `login` VALUES (1, 'admin1', '', 'Fri 26th Mar 2004 06:56 pm', 'Mon 10th May 2004 08:52 pm', '1080323790');
INSERT INTO `login` VALUES (2, 'admin1', '', 'Tue 30th Mar 2004 07:48 pm', 'Mon 10th May 2004 08:52 pm', '1080668898');
INSERT INTO `login` VALUES (3, 'admin1', '', 'Tue 30th Mar 2004 08:48 pm', 'Mon 10th May 2004 08:52 pm', '1080672515');
INSERT INTO `login` VALUES (4, 'admin1', '', 'Mon 05th Apr 2004 08:48 pm', 'Mon 10th May 2004 08:52 pm', '1081190916');
INSERT INTO `login` VALUES (5, 'admin1', '', 'Mon 05th Apr 2004 08:59 pm', 'Mon 10th May 2004 08:52 pm', '1081191554');
INSERT INTO `login` VALUES (6, 'admin1', '', 'Mon 05th Apr 2004 09:09 pm', 'Mon 10th May 2004 08:52 pm', '1081192181');
INSERT INTO `login` VALUES (7, 'admin1', '', 'Mon 05th Apr 2004 09:10 pm', 'Mon 10th May 2004 08:52 pm', '1081192215');
like the export file in phpmyadmin.
How can i get the second format ready to reload ?
Tks !!
Posted: Sun Aug 14, 2005 7:16 pm
by feyd
you have to create it, unless you want to use other tools mentioned already.