当使用git终端时,laravel宅基地“找不到司机”

问题描述 投票:0回答:3

当我在Windows上使用git终端并尝试运行“php artisan migrate”来迁移我的表时,我收到此错误:

1 PDOException::(“找不到驱动程序”)

但是当我通过ssh登录到我的虚拟框“vagrant ssh”时,当我导航到站点文件夹并运行“php artisan migrate”时,它工作得很好。

出现这种情况的原因是什么?我该如何解决?

完整的错误消息:

$ php artisan migrate

   Illuminate\Database\QueryException  : could not find driver (SQL: select * fr
om information_schema.tables where table_schema = aff and table_name = migration
s)

  at C:\Users\jarro\Documents\sites\aff\vendor\laravel\framework\src\Illuminate\
Database\Connection.php:664
    660|         // If an exception occurs when attempting to run a query, we'll
 format the error
    661|         // message to include the bindings with SQL, which will make th
is exception a
    662|         // lot more helpful to the developer instead of just the databa
se's errors.
    663|         catch (Exception $e) {
  > 664|             throw new QueryException(
    665|                 $query, $this->prepareBindings($bindings), $e
    666|             );
    667|         }
    668|

  Exception trace:

  1   PDOException::("could not find driver")
      C:\Users\jarro\Documents\sites\aff\vendor\laravel\framework\src\Illuminate
\Database\Connectors\Connector.php:68

  2   PDO::__construct("mysql:host=192.168.10.10;port=3306;dbname=aff", "homeste
ad", "secret", [])
      C:\Users\jarro\Documents\sites\aff\vendor\laravel\framework\src\Illuminate
\Database\Connectors\Connector.php:68

  Please use the argument -v to see more details.
php git laravel ssh homestead
3个回答
1
投票

当你使用php artisan migrate或种子你需要进入宅基地虚拟机终端并运行这些命令否则它将失败,因为它会发现虚拟机mysql不是你的Windows mysql

  1. homestead ssh
  2. cd Code/yourapp
  3. php artisan migratephp artisan db:seed

我假设您有类似于navicat或任何数据库查看器,可以访问您的mysql虚拟机内部以跟踪您的命令是否正常工作。


0
投票

我发现这个更好用。虽然你可以做了什么Winston说(标记正确的答案)后搞乱了一段时间,我删除了Ampps并下载了Xampp并重新安装了composer并将php exe路径放到了xampp。现在,我可以在本地计算机上而不是在虚拟机上执行所有操作。

只是想我会把它放在这里! :d


0
投票

我有同样的问题,这是因为/.env文件中的错误数据库主机:

DB_HOST = 127.0.0.1

把它设置为你的流浪者主人(对我来说是homestead.test):

DB_HOST = homestead.test

预计您已将其映射到Windows“hosts”文件中:

192.168.10.10 homestead.test

© www.soinside.com 2019 - 2024. All rights reserved.