Reputation:
when i use the git terminal on windows and try to run "php artisan migrate" to migrate my tables, i get this error:
1 PDOException::("could not find driver")
But when i log in via ssh to my virtual box "vagrant ssh", it works perfectly fine when i navigate to the site folder and run "php artisan migrate".
Any reason why this is happening? How can i fix it?
Complete error message:
$ 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.
Upvotes: 1
Views: 1544
Reputation: 69
Try to destroy the Vagrant Virtual Machine, then run Vagrant again. This will recreate your Vagrant Virtual Machine
Run these commands from a terminal in the Homestead folder where the Vagrant file is located.
Commands:
vagrant destroy --force
vagrant up
Upvotes: 0
Reputation: 1346
when you use php artisan migrate
or seed you need to go inside of homestead virtual machine terminal and run these commands otherwise it will fail because it will find the virtual machine mysql not your windows mysql
homestead ssh
cd Code/yourapp
php artisan migrate
or php artisan db:seed
I assume you have like navicat or any database viewer that can access inside your mysql virtual machine to trace if your commands are working or not.
Upvotes: 2
Reputation: 21
I had the same problem, it`s because of the wrong db host in /.env file:
DB_HOST=127.0.0.1
Set it to your vagrant host (homestead.test for me):
DB_HOST=homestead.test
Expected that you have mapped it in Windows 'hosts' file:
192.168.10.10 homestead.test
Upvotes: 0
Reputation:
I have found this to work better. While you can do what Winston said (Marked correct Answer) after messing around with it for a while, i removed Ampps and downloaded Xampp and re-installed composer and put the php exe path to the xampp. Now i can do everything on my local machine instead on the Virtual Machine.
Just thought i would drop this in here! :D
Upvotes: 0