简体   繁体   English

一般错误:'“mysqldump”' 未被识别为内部或外部命令

[英]General error : '“mysqldump”' is not recognized as an internal or external command

I use Laravel Spatie Backup, the installation is complete, first running this $ composer require spatie/laravel-backup我用的是Laravel Spatie 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

and then $ php artisan vendor:publish --provider="Spatie\\Backup\\BackupServiceProvider"然后 $ 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.

But when I run但是当我跑

php artisan backup:run

this error appear出现这个错误

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.备份失败,因为:转储过程失败,退出代码为 1:一般错误:'"mysqldump"' 不是内部或外部命令、可运行的程序或批处理文件。

NOTE : I use Laravel version 5.6 and Spatie v.5注意:我使用 Laravel 5.6 版和 Spatie v.5

In your config/database.php file, edit the mysql database config and add:在您的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
],

In your config/database.php file, edit the mysql database config and add:在您的config/database.php文件中,编辑 mysql 数据库配置并添加:

'dump_command_path' =>' '

Which is the absolute path to where mysqldump lives on your system That path is probably this, or something very similar: C:\\xampp\\mysql\\bin哪个是 mysqldump 在你的系统上的绝对路径那个路径可能是这个,或者非常相似的东西: C:\\xampp\\mysql\\bin

I face this issue我面临这个问题

please follow this https://spatie.be/docs/laravel-backup/v4/installation-and-setup#dumping-the-database请按照此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
            ], 
    ],

It'll fix your problem by adding this line to your config/database file for taking backup of files and database.它将通过将此行添加到您的配置/数据库文件以备份文件和数据库来解决您的问题。 It will work 100%.它将 100% 工作。

Here is the Image to show where you have made changes.这是显示您进行更改的位置的图像。 在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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