6

Starting backup...

Dumping database hms...

Backup failed because The dump process failed with exitcode 2 : Misuse of shell builtins : mysqldump: Got error: 2004: "Can't create TCP/IP socket (10106 "Unknown error")" when trying to connect\r\n

I got the following error while trying to

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

$output=Artisan::output();

using php artisan backup:run on the command line works fine. enter image description here

calling it laravel's Artisan gives that error.

I correctly assign the config/database.php dump

'mysql' => [
            ...
            'dump' => [
               'dump_binary_path' => 'C:\xampp\mysql\bin',
               'use_single_transaction',
               'timeout' => 60 * 5, 
               'exclude_tables' => ['table1', 'table2'],
            ]  
        ],

Please, help me.

Vijay S
  • 282
  • 2
  • 7
  • 15

5 Answers5

0

**Just put your project C:\xampp\htdocsfolder in and open it in a browser:

yourdomain/PROJECT-NAME/public

it works fine for me**

0

Try this way, I had the same issue, the artisan backup:run successfully generating the backup but when I try to call it using Artisan from route or controller, I got the same error, but I found another solution for it, which I'm using here Shell_exec make sure its enabled in your xampp/wamp

Note: I'm using PHP 7.4.29

Check if shell_exec is Enabled

if(function_exists('shell_exec')) {
    echo "shell_exec is enabled";
}

web.php

Route::get('/export',function(){
    shell_exec("C:/xampp/mysql/bin/mysqldump -h localhost -u root test > C:/xampp/htdocs/projects/main.sql");
  });

Also check this reference for help: https://stackoverflow.com/a/15294585/13804634

I also, open a dispute on spatie/laravel-backup but, I guess there is a problem in my environment. https://github.com/spatie/laravel-backup/issues/1578

Make sure your mysqldump set in your environment variables 'mysqldump' is not recognized as an internal or external command

codelone
  • 604
  • 8
  • 17
0

I had invested a lot of time, particularly in this specific issue and found the solution in my case...as php artisan backup: run command successfully backups the database using CLI...so there is no issue with the package itself... I'm using "spatie/laravel-backup": "^6.16"

route/web.php create a route to test the artisan command

Route::get('/backup', function() {
  Artisan::call('backup:run'); 
});

As I can see when we try to launch the laravel application we use CLI for example:

php artisan serve then your project will host on 127.0.0.1:8080/project/ or any given port.

Instead, try to access the project directly from your localhost without artisan and then navigate to your project directory from the address bar localhost/project/backup now, it will generate a backup in storage/app/public/ directory.

Must try this if you tried everything...

codelone
  • 604
  • 8
  • 17
0

for me, in this case php artisan serve is not working.

and i try virtualhost for run aplication in locale.

<VirtualHost *:80>
    ServerName apps.web
    DocumentRoot "C:\xampp\htdocs\apps\public"
    <Directory "C:\xampp\htdocs\apps\public>"
        DirectoryIndex index.php
        AllowOverride All
        Order allow,deny
        Allow from all
        <IfModule mod_authz_core.c>
        Require all granted
        </IfModule>
    </Directory>
</VirtualHost>
-2

Just put your project folder to C:\xampp\htdocs then open it at the browser:

yourdomain/PROJECT-NAME/public

and it just works fine for me

vreedom18
  • 341
  • 2
  • 13