General error : '"mysqldump"' is not recognized as an internal or external command

General error : '"mysqldump"' is not recognized as an internal or external command

我用的是LaravelSpatie Backup,安装完成, 首先 运行宁此 $ composer require spatie/laravel-backup

$ composer require spatie/laravel-backup

Using version ^5.6 for spatie/laravel-backup
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 3 installs, 0 updates, 0 removals
  - Installing spatie/temporary-directory (1.1.3): Downloading (100%)
  - Installing spatie/db-dumper (2.9.0): Downloading (100%)
  - Installing spatie/laravel-backup (5.6.0): Downloading (100%)
spatie/laravel-backup suggests installing guzzlehttp/guzzle (Allows notifications to be sent via Slack)
Writing lock file
Generating optimized autoload files

然后 $php artisan vendor:publish --provider="Spatie\Backup\BackupServiceProvider"

 $ php artisan vendor:publish --provider="Spatie\Backup\BackupServiceProvider"

Copied File [\vendor\spatie\laravel-backup\config\backup.php] To [\config\backup.php]
Copied Directory [\vendor\spatie\laravel-backup\resources\lang] To [\resources\lang\vendor\backup]
Publishing complete.

但是当我 运行

php artisan backup:run

出现这个错误

Backup failed because: The dump process failed with exitcode 1 : General error : '"mysqldump"' is not recognized as an intern al or external command, operable program or batch file.

注意:我使用Laravel 5.6 版 和 Spatie v.5

在您的 config/database.php 文件中,编辑 mysql 数据库配置并添加:

'dump' => [
   'dump_binary_path' => 'C:/xampp/mysql/bin/', // only the path, so without `mysqldump` or `pg_dump`
   'use_single_transaction',
   'timeout' => 60 * 5, // 5 minute timeout
],

在您的 config/database.php 文件中,编辑 mysql 数据库配置并添加:

'dump_command_path' =>' '

mysqldump 在您的系统上的绝对路径该路径可能是这个,或者非常相似的路径:C:\xampp\mysql\bin

我遇到这个问题

请关注 https://spatie.be/docs/laravel-backup/v4/installation-and-setup#dumping-the-database

//config/database.php
'connections' => [
    'mysql' => [
        'driver'    => 'mysql'
        ...,
        'dump' => [
                'dump_binary_path' => 'D:/xampp/mysql/bin/', // only the path, so without `mysqldump` or `pg_dump`
                'use_single_transaction',
                'timeout' => 60 * 5, // 5 minute timeout
            ], 
    ],

它将此行添加到您的 config/database 文件以备份文件和数据库,从而解决您的问题。它将 100% 有效。

这是显示您所做更改的图像。