Just having some issue trying to php artisan migrate a mysql database to work on in a local environment. I have been trying all day to get my database to migrate, and everything I could dig up tells me that my credentials should be correct.
database.php
'mysql' => [
'driver' => 'mysql',
'host' => env('DB_HOST', 'localhost'),
'port' => env('DB_PORT', '3306'),
'database' => env('DB_DATABASE', 'homestead'),
'username' => env('DB_USERNAME', 'homestead'),
'password' => env('DB_PASSWORD', 'secret'),
'unix_socket' => env('DB_SOCKET', ''),
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci',
'prefix' => '',
'strict' => false,
'engine' => null,
]
as for my .env
DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=homestead
DB_USERNAME=homestead
DB_PASSWORD=secret
I have tried php artisan config:clear and read through the documentations and tried nearly all of the fixes suggested by other users on similar questions to no avail.
from your data, you should have
mysql -u homestead -h localhost -p secret
[enter link description here][see this answer]
set password and grant privelege
mysql> SET PASSWORD FOR 'homestead'@'localhost' = PASSWORD('secret');
grant priveleges to your database
GRANT SELECT ON homestead.* TO 'homestead'@'secret';
in the above code first homestead represents database name
try flush privileges from mysql client
mysql> FLUSH PRIVILEGES;
if you're running php artisan migrate command outside homestead, you should change the port to 33060. then change it back again to 3306 after migration.
otherwise you need to do it inside homestead via an SSH connection (vagrant ssh)