2.8.4.2.3. Setting up a database connection in Laravel
Attention!
The connection will not work with localhost. The host address must be taken from the data to connect to the database.Database connection data in Laravel are specified in the configuration file of the database settings:
- In case of using a file
.env
you need to change the lines:DB_HOST=host DB_PORT=3306 DB_DATABASE=база_DB data_USERNAME=login DB_PASSWORD=password
- In case of using a file
config/database.php
you need to change the lines:'mysql' => [ 'driver' => 'mysql', 'host' => env('DB_HOST', 'host'), 'port' => env('DB_PORT', '3306'), 'database' => env('DB_DATABASE', 'база_data'), 'username' => env('DB_USERNAME', 'login'), 'password' => env('DB_PASSWORD', 'password'), 'unix_socket' => env('DB_SOCKET', ''),
Please note that after editing the configuration files, you may need to update the cache. The update is performed by the commands:
php artisan config:clear php artisan config:cache
You can select the required PHP version by instructions.
You can make changes to files using filemanager or any FTPclient.