Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to connect Remote Database in Laravel App?

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.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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

>Solution :

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

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading