Trying to connect laravel 8 app in production to mysql database. Have tried to follow documentation but it isn’t working.
.env file as follows
DB_CONNECTION=mysql DB_HOST=127.0.0.1 DB_PORT=3306 DB_DATABASE=domain_laravelapp DB_USERNAME=domain_admin DB_PASSWORD=password
config/database.php as follows
'mysql' => [ 'driver' => 'mysql', 'url' => env('domain.co.uk:3306'), 'host' => env('DB_HOST', '127.0.0.1'), 'port' => env('DB_PORT', '3306'), 'database' => env('domain_laravelapp', 'forge'), 'username' => env('domain_admin', 'forge'), 'password' => env('password', ''), 'unix_socket' => env('DB_SOCKET', ''), 'charset' => 'utf8mb4', 'collation' => 'utf8mb4_unicode_ci', 'prefix' => '', 'prefix_indexes' => true, 'strict' => false, 'engine' => null, 'options' => extension_loaded('pdo_mysql') ? array_filter([ PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'), ]) : [], ],
when i run php artisan migrate --force
, i get this error:
SQLSTATE[28000] [1045] Access denied for user 'forge'@'localhost' (using password: NO) (SQL: select * from information_schema.tables where table_schema = forge and table_name = migrations and table_type = 'BASE TABLE') at vendor/laravel/framework/src/Illuminate/Database/Connection.php:678 674▕ // If an exception occurs when attempting to run a query, we'll format the error 675▕ // message to include the bindings with SQL, which will make this exception a 676▕ // lot more helpful to the developer instead of just the database's errors. 677▕ catch (Exception $e) { ➜ 678▕ throw new QueryException( 679▕ $query, $this->prepareBindings($bindings), $e 680▕ ); 681▕ } 682▕ +33 vendor frames 34 artisan:37 IlluminateFoundationConsoleKernel::handle(Object(SymfonyComponentConsoleInputArgvInput), Object(SymfonyComponentConsoleOutputConsoleOutput))
Can anybody please explain what I’m going wrong?
It seems to be ignoring both those files.
Advertisement
Answer
write in terminal :
php artisan cache:clear php artisan config:clear