How can i connect my laravel to an extneral Database?
Example: I have a laravel on my local machine which is running on xammp. And i want it to connect to a cloud Server database.
Open the .env file and edit it. Just set up correct external DB credentials:
DB_CONNECTION=mysql
DB_HOST=127.0.0.1 // set external DB_Host
DB_PORT=3306 // Your Database Port
DB_DATABASE= // Your Database Name
DB_USERNAME= // Your Database Username
DB_PASSWORD= // Your Database Password
DB_USERNAME should be set to root if you do not have a default username in the installation time
If no password is set on the database, just clear it DB_PASSWORD
After .env edit, must be clear cache:
php artisan config:cache
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With