I recently did a fresh install of mysql 8.0.19 via homebrew on macOS High Sierra 10.13.6. I can see that the mysql service is started when I do brew services list. I can also login via the console with mysql -u root and execute queries and whatnot.
I've installed a fresh Laravel project using Valet but cannot run database migrations. My environment variables all look to be correct:
DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=laravel
DB_USERNAME=root
DB_PASSWORD=
I can connect to MySQL Workbench using this information (no root pw). Yet, whenever I run php artisan migrate I get no errors and no console output whatsoever. It just gets stuck. Same thing happens when I go in with php artisan tinker and then DB::connection()->getPdo(). No output and no errors. Nothing gets logged in storage/logs either.
Relevant config/database.php:
...
'default' => env('DB_CONNECTION', 'mysql'),
'connections' => [
'mysql' => [
'driver' => 'mysql',
'url' => env('DATABASE_URL'),
'host' => env('DB_HOST', '127.0.0.1'),
'port' => env('DB_PORT', '3306'),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'unix_socket' => env('DB_SOCKET', ''),
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci',
'prefix' => '',
'prefix_indexes' => true,
'strict' => true,
'engine' => null,
'options' => extension_loaded('pdo_mysql') ? array_filter([
PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
]) : [],
],
],
...
Dumping DB::connection() on a random view yields the correct config:
protected 'config' =>
array (size=15)
'driver' => string 'mysql' (length=5)
'host' => string '127.0.0.1' (length=9)
'port' => string '3306' (length=4)
'database' => string 'laravel' (length=7)
'username' => string 'root' (length=4)
'password' => string '' (length=0)
'unix_socket' => string '' (length=0)
'charset' => string 'utf8mb4' (length=7)
'collation' => string 'utf8mb4_unicode_ci' (length=18)
'prefix' => string '' (length=0)
'prefix_indexes' => boolean true
'strict' => boolean true
'engine' => null
'options' =>
array (size=0)
empty
'name' => string 'mysql' (length=5)
php artisan make:policy Foobarworks as expected. I can also load views in the browser just fine, just no DB interaction.envfile overwrites your config file?php artisan tinkerandenv('DB_DATABASE', 'foobar')shows the correct info from the.envfile. Theconfig/database.phpfile also looks correct.envfile toconfig\database.phpfile