This is a Standard PHP/MYSQL error. But, are you using Homestead, Valet or just a local server like WAMP or MAMP?
If you are using homestead then you need to connect via 192.168.10.10. Check your .env file and see what the details are there.
Hi there, so I'm new to laravel and frameworks in general, I've been following the tutorials on the laracast and everything's been amazing so far, but then when I got to the data migrations video and hit a bump. In the tutorial video, I'm doing a data migration to sqlite, but when i tried to do the migration i kept getting the error [PDOException] could not find driver. Anyways, through some google searching I did sudo apt-get install php5-mysql and now i'm getting a different error when I try migrating, [PDOException] SQLSTATE[HY000] [2003] Can't connect to MySQL server on '127.0.0.1' (111). I'm unsure of how to resolve this. I've tried googling the issue but nothing's resolved it. Here is the default configurations for the database.php file as well. Any help would be appreciated! Thanks!
'connections' => [
'sqlite' => [
'driver' => 'sqlite',
'database' => env('DB_DATABASE', database_path('database.sqlite')),
'prefix' => '',
],
'mysql' => [
'driver' => 'mysql',
'host' => env('DB_HOST', 'localhost'),
'port' => env('DB_PORT', '3306'),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
'strict' => false,
'engine' => null,
],
'pgsql' => [
'driver' => 'pgsql',
'host' => env('DB_HOST', 'localhost'),
'port' => env('DB_PORT', '5432'),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'charset' => 'utf8',
'prefix' => '',
'schema' => 'public',
],
],
This is a Standard PHP/MYSQL error. But, are you using Homestead, Valet or just a local server like WAMP or MAMP? If you are using homestead then you need to connect via 192.168.10.10. Check your .env file and see what the details are there.
@Jaytee to be honest i'm unsure how i got the local server up. I just followed the video tutorial and installed it via composer and i was able to serve it up locally.
You are getting a MySQL error although you should be expecting to be using a SQLite database - check if your .env file has a key-value pair: DB_CONNECTION=sqlite If you are intending to use a SQLite database, make sure that is exists, e.g. the fallback DB_DATABASE in config/database.php is database/database.sqlite
@tykus_ikus Turns out I didn't change my .env enough, by default, the .env file had this in it
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=homestead
DB_USERNAME=homestead
DB_PASSWORD=secret
Just changing the DB_CONNECTION to sqlite kicked up another error ([InvalidArgumentException] Database (homestead) does not exist.). So to fix this I completely deleted it and changed it to
DB_CONNECTION=sqlite
DB_FILE=database.sqlite
Thank you guys both for the help!
Please or to participate in this conversation.