简体   繁体   中英

spatie/laravel-backup “mysqldump” doesn't recognized when I run it through Artisan class

I'm using spatie/laravel-backup in a WAMP localhost.

It works fine when I type manually in the windows cmd:

php artisan backup:run

But when I try to run the backup using the laravel Artisan class:

Artisan::call('backup:run');

It throw an error:

'mysqldump' not recognized ...

In the laravel mysql config I've also specified the path to the dumper:

'mysql' => [
            'driver' => 'mysql',
            // ...
            'dump' => [
                'dump_binary_path' => 'E:/wamp/wamp64/bin/mysql/mysql5.7.9/bin',
           ],
        ],

How can i fix that?


EDIT

Probably it's just support "bug" for windows (finded out thanks Loek's answer), as the author says , so can I run a backup in a controller without a command safely? maybe with something like:

use Spatie\Backup\Tasks\Backup\BackupJobFactory;

BackupJobFactory::createFromArray(config('laravel-backup'))->run();

As the command itself.

I believe it's the forward slashes. Try this:

'mysql' => [
        'driver' => 'mysql',
        // ...
        'dump' => [
            'dump_binary_path' => 'E:\\wamp\\wamp64\\bin\\mysql\\mysql5.7.9\\bin',
       ],
    ],

EDIT

Support for Windows is wonky at best, with multiple "This package doesn't support Windows" comments from the creators on GitHub issues. This one is the latest: https://github.com/spatie/laravel-backup/issues/311

It could also be a permission problem. Executing from the command line is probably happening from another user than executing from the web server, so Windows is denying access to mysqldump.

2nd edit

As long as you make sure the controller only gets called when it needs to be, I don't see why this wouldn't work!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM