Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

$ 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"

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.

NOTE: I use Laravel version 5.6 and Spatie v.5

like image 856
Nasser Ali Karimi Avatar asked Apr 12 '18 04:04

Nasser Ali Karimi


People also ask

Why Mysqldump is not working?

If mysqldump is not identified by the cmd prompt that means it cannot recognize where the mysqldump.exe is located. You need to add path of the directory where the exe is located in the PATH variable under environment variables. After doing that your command will start working in the cmd prompt.

How do I run Mysqldump on Windows?

To dump/export a MySQL database, execute the following command in the Windows command prompt: mysqldump -u username -p dbname > filename. sql . After entering that command you will be prompted for your password.

What is Mysqldump command?

It dumps one or more MySQL databases for backup or transfer to another SQL server. The mysqldump command can also generate output in CSV, other delimited text, or XML format.


4 Answers

I face this issue

please follow this 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
            ], 
    ],
like image 63
Najathi Avatar answered Oct 22 '22 17:10

Najathi


In your config/database.php file, edit the mysql database config and add:

'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
],
like image 23
Nasser Ali Karimi Avatar answered Oct 22 '22 17:10

Nasser Ali Karimi


In your config/database.php file, edit the mysql database config and add:

'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

like image 33
Hiren Gohel Avatar answered Oct 22 '22 16:10

Hiren Gohel


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%.

Here is the Image to show where you have made changes. enter image description here

like image 25
Kaleemullah Avatar answered Oct 22 '22 17:10

Kaleemullah