简体   繁体   中英

Backup .sql from laravel

I'm going to backup my database .sql file from laravel. when I use artisan command from cmd, the backup file will generated with no issue. but when i do that from controller I got this error.

How to fix this?

mysqldump: Got error: 2004: "Can't create TCP/IP socket (10106 "Unknown error")"

You can use db-dumper package to backup your database.

Installing:

composer require spatie/db-dumper

Usage:

Spatie\DbDumper\Databases\MySql::create()
    ->setDbName($databaseName)
    ->setUserName($userName)
    ->setPassword($password)
    ->dumpToFile('dump.sql');

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