laravel数据库迁移报错:'mysqldump' is not recognized as an internal or external command

2023-06-01 00:00:00 数据库 报错 迁移

在windows10系统中使用phpStudy运行laravel项目

环境变量

D:\phpStudy\MySQL\bin

laravel框架执行迁移命令

php artisan schema:dump

报错:

’mysqldump’ is not recognized as an internal or external command,
vendor\symfony\process\Process.php:272
    268▕      */
    269▕     public function mustRun(callable $callback = null, array $env = []): self
    270▕     {
    271▕         if (0 !== $this->run($callback, $env)) {
  ➜ 272▕             throw new ProcessFailedException($this);
    273▕         }
    274▕
    275▕         return $this;
    276▕     }


解决方式:

需要在配置文件config/database.php中配置

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

就可以了


相关文章