Page 1 of 1

Database sql restore problem

PostPosted: 11. November 2016 20:31
by Tee shot
hi,

I use a script to restore my database to my host, but I can not manage it under xampp, I do not understand or is the problem.

Code: Select all
$host= 'localhost';
         $user= 'root';
         $pass= 'my_passl';
         $db= 'my_base';
         //$db_charset = "utf8";
         $chemin = getenv('DOCUMENT_ROOT').'/admin/sauvegarde_mysql/';
         // Décompresser le gzip et l'importer dans la base de données
         system(sprintf(
         'gunzip -c %s/'.$_GET['fichier'].' | mysql -h %s -u %s -p%s %s',
         $chemin,
         $host,
         $user,
         $pass,
         $db
         ));


Thank

Re: Database sql restore problem

PostPosted: 11. November 2016 21:01
by tm01
is it a code from a linux environment (or did you install "gunzip" as a sys variable)?
why don't you just use phpmyadmin to restore your backup?
you should provide your log files (apache error.log and php_error.log) and not just your php code.

Re: Database sql restore problem

PostPosted: 11. November 2016 21:33
by Nobbie
Tee shot wrote:I use a script to restore my database


But this is not a script from Xampp. Ask the author of the script, if something is going wrong.

Re: Database sql restore problem

PostPosted: 11. November 2016 22:38
by Tee shot
Thanks for your answers.
Here is the extract of the log file: 'gunzip' is not recognized as internal command
Or external, an executable program or a batch file.
I can't go through phpmyadmin, I need a script that could work just online and locally.

Thank

Re: Database sql restore problem

PostPosted: 11. November 2016 22:49
by tm01
Well, thats the problem.
Your script requires at least gunzip and mysql as global terminal commands. So its not a problem of xampp, apache, php or anything else related to this forum - its an issue with your code and your system environment.
i don't know what you are trying to do or why you can't use phpmyadmin (its accessible local and online if you wish), but i think you should look for a different way or other scripts that are working with native php commands and not with external resources. For example I don't know why your script is executing the systems mysql instead of using php's mysqli syntax.

Re: Database sql restore problem

PostPosted: 12. November 2016 00:06
by Tee shot
Gunzip is not recognized under xampp?
It's a shame I'll look for another way, but I need to go through a script.

Thank

Re: Database sql restore problem

PostPosted: 12. November 2016 00:14
by tm01
you can set an environment variable if you manage to install gunzip on your system. but i don't know if gunzip for windows even exists.
it has nothing to do with xampp, apache, php or anything else.
Lets give you an example: You sit at home in europe and look through the window of your living room. You've heard some people see palm trees and camels. Now you ask your architect whats wrong with your house or your window in your living room. The architect will tell you the same like we did here: plant a palmtree and buy a camel for your garden or move to a house in egypt. There is nothing wrong with your house or your window.

Re: Database sql restore problem

PostPosted: 12. November 2016 12:59
by Nobbie
Tee shot wrote:Gunzip is not recognized under xampp?
It's a shame I'll look for another way,


OMG....

It is not a question of Xampp, you are running a script which obviously is designed to run under LInux (and not under Windows). Windows(!) does not recognize "gunzip", its not a Xampp issue. Got it?! There is no "gunzip" in Windows.

Simply move your project to a Linux PC, install Xampp and run the script - eh voila, you will see, Xampp recognizes "gunzip" under Linux...