s_user
s_user

Reputation: 634

Laravel MySQL database setup error

I want to use a MySQL database with my Laravel 5.2 framework. I'm not able to access phpMyAdmin after I run php artisan serve and open a localhost page.

My .env file :

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_DATABASE=people
DB_USERNAME=pftest
DB_PASSWORD="pftest_2016#9"

After doing this, I ran php artisan migrate and got the following error:

[PDOException] could not find driver 

Following which, I have installed the php-mysql extension and checked for its presence in php.ini file. But I'm still getting the following error :

[PDOException]  SQLSTATE[HY000] [2002] Connection refused

So what is the issue and how to solve it?

Upvotes: 3

Views: 310

Answers (1)

s_user
s_user

Reputation: 634

In the .env file, set

APP_ENV=local
DB_PORT=3306

and then run php artisian migrate --env="local"

Same is valid for dev,production env.

Upvotes: 2

Related Questions