Home > Software engineering >  How to connect Remote Database in Laravel App?
How to connect Remote Database in Laravel App?

Time:11-29

I am using Laravel 8 and I am working on Local environment and I want to use Remote Database in my Local Laravel App. I am using Bluehost I have created database and generate credentials for database but when I use query I face following issue.

SQLSTATE[HY000] [1045] Access denied for user 'ngtonlin_cron_jobs_test'@'Shared IP Address.braintel.net.pk' (using password: YES) (SQL: select * from `users`)

I also added credentials in .env

DB_CONNECTION=mysql
DB_HOST=Shared IP Address
DB_PORT=3306
DB_DATABASE=db_name
DB_USERNAME=user_name
DB_PASSWORD="D$8]!2?^kg(!"

I have added below code for querying.

Route::get('/', function () {
$users = DB::table('users')->get();
dd($users);
});

CodePudding user response:

You'll need to add your current IP to access the database on Bluehost. You can read more about it here

  • Related