Welcome Guest. Please Login or Register  


You are here: Index > AMPPS > General Support > Topic : Mysql Dump/backUP

2


Threaded Mode | Print  

Mysql Dump/backUP
Nube
Group: Member
Post Group: Newbie
Posts: 29
Status:
Hi :) thanks for the code but unfortunatly still it doesn't work.. i don't know why.. this time i can see the console opening and the dump on scrolling inside it but the file is still empty..

I modified the code a bit to make it works on my system, yours didn't (don't know why)

Now, everytime i run the backup files, windows opens a requester asking me for permission (in my system there an admin and a user).. I also tried to modified the property of the mysqldump.exe giving it the permission (run as administrator)..

Here my code:

PHP Code

<?php

$host
="localhost";
$user="root";
$password="root";
$db="trasporti";
$file='C:/Program Files/Ampps/www/t6/backup/';
$file.="dump.sql";

$db_connect=mysql_connect("$host""$user""$password");

mysql_select_db("$db");

$mydump '"C:/Program Files/Ampps/mysql/bin/mysqldump.exe"';
$command $mydump.' -h '.$host.' -u '.$user.' -p"'.$password.'" '.$db.' > "'.$file.'"';
$temp 'C:/Program Files/Ampps/temp/t'.rand(1999).'.bat';
$fp fopen ($temp"w+");
fwrite($fp$command);
fclose($fp);

@
exec('"'.$temp.'"'$array$ret);
unlink($temp); 

mysql_close($db_connect);

?>



I suspect there is something wrong in my apache/mysql setup or something that i am missing.. and also i think that the comand (mysqldump.exe) should be inserted into my shell path.. Do you know how to do this?

Thanks Davide,
IP: --   

Mysql Dump/backUP
tidus
Group: Member
Post Group: Super Member
Posts: 1121
Status:
Since you are specifying the whole path, mysqldump.exe need not be in environment variable. If you still want it in environment then follow this link, add the directory path i.e path/to/Ampps/mysql/bin to PATH variable.

For XP : http://support.microsoft.com/kb/310519

For Windows 7 : http://geekswithblogs.net/renso/archive/2009/10/21/how-to-set-the-windows-path-in-windows-7.aspx

If you are using any other OS just search in google "set PATH environment variable in YOUR_OS_NAME",  you should be able to find easily.


-----------------------
Follow AMPPS on,
Twitter : https://twitter.com/AMPPS_Stack
Facebook :  http://www.facebook.com/softaculousampps
Google+ : https://plus.google.com/+AmppsStack
IP: --   

Mysql Dump/backUP
Nube
Group: Member
Post Group: Newbie
Posts: 29
Status:
I still have the problem, btw i tried to use phpmyadmin and i was able to make a dump.. so what's the difference between using phpmyadmin and mysqldump directly??

Maybe i have to set some info into Apache or PHP ini file? i also noticed that you installed AMPPS in C:\ instead i Installed it in C:\Program Files\

maybe is this? or maybe the fact that i have an administrator and a user?..

I noticed that when i try to dump the database (from php or directly from the console) a console pops up showing all the data flowing inside (like if it was doing the dump) but then the file is still empty. If i did it from the console another console pops up, showing the data but no dump is done..

any ideas?, please help me.. i am going crazy..
IP: --   

Mysql Dump/backUP
tidus
Group: Member
Post Group: Super Member
Posts: 1121
Status:
>> I still have the problem, btw i tried to use phpmyadmin and i was able
to make a dump.. so what's the difference between using phpmyadmin and
mysqldump directly??

Nothing, both do the same work. phpMyAdmin is a UI for MySQL & mysqldump is used in command line.

>> Maybe i have to set some info into Apache or PHP ini file?

You can configure according to your need. Default setting, Development setting or Production setting. You should get help from other PHP forums for better knowledge.

>> i also noticed that you installed AMPPS in C:\ instead i Installed it in
C:\Program Files\ maybe is this? or maybe the fact that i have an administrator and a user?..

Path or Users won't matter here

>> I noticed that when i try to dump the database (from php or directly
from the console) a console pops up showing all the data flowing inside
(like if it was doing the dump) but then the file is still empty. If i
did it from the console another console pops up, showing the data but no
dump is done..

I tested it again with my php code & command line directly, it is working without any issues. Recheck your command. Try running the command directly from command prompt and not from a batch file. Refer MySQL documentation for more info.



-----------------------
Follow AMPPS on,
Twitter : https://twitter.com/AMPPS_Stack
Facebook :  http://www.facebook.com/softaculousampps
Google+ : https://plus.google.com/+AmppsStack
IP: --   

Mysql Dump/backUP
Nube
Group: Member
Post Group: Newbie
Posts: 29
Status:
Hi :) finally i found the code that works for me! here it is:
PHP Code

<?php $command 'mysqldump -h localhost -u root -proot --database "trasporti" -r "C:Program FilesAmppswwwt6backupbackup.sql"';
system($command);?>

it seems that the -r is the key and also the add of --database
IP: --   

Mysql Dump/backUP
tidus
Group: Member
Post Group: Super Member
Posts: 1121
Status:
Good to know that the code is working.

Please let us know if you need further information regarding AMPPS.

-----------------------
Follow AMPPS on,
Twitter : https://twitter.com/AMPPS_Stack
Facebook :  http://www.facebook.com/softaculousampps
Google+ : https://plus.google.com/+AmppsStack
IP: --   

Mysql Dump/backUP
raghubodi
Group: Member
Post Group: Newbie
Posts: 2
Status:
The mysqldump client is a backup program
        originally written by Igor Romanenko. It can be used to dump a
        database or a collection of databases for backup or transfer to
        another SQL server (not necessarily a MySQL server). The dump
        typically contains SQL statements to create the table, populate
        it, or both. However, mysqldump can also be
        used to generate files in CSV, other delimited text, or XML
        format.
     

-----------------------
website development services

IP: --   

« Previous    Next »

Threaded Mode | Print  

2


Jump To :


Users viewing this topic
1 guests, 0 users.


All times are GMT. The time now is November 22, 2019, 11:55 pm.

  Powered By AEF 1.0.8 © 2007-2008 Electron Inc.Queries: 11  |  Page Created In:0.483