3

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?

Paulie-C
  • 1,674
  • 1
  • 13
  • 29
s_user
  • 586
  • 2
  • 8
  • 19
  • Check the password , "pftest_2016#9" or pftest_2016#9 ? – Vinod VT Jun 07 '16 at 11:45
  • 1
    Run `php --ini` from the command line and make sure it is using the same .ini file you think it is using. – Pitchinnate Jun 07 '16 at 15:44
  • @kirangadhvi its not same.. read the error.. my error is : [PDOException] SQLSTATE[HY000] [2002] Connection refused – s_user Jun 08 '16 at 04:08
  • @Pitchinnate After I ran php --ini , I found the configuration file pointing at this place: /etc/php/7.0/cli/php.ini. Where is it suppose to point ?? how to know which path its suppose to point ?? – s_user Jun 08 '16 at 04:17
  • @s_user hey please check this link and check answer i think that's what you looking for. http://stackoverflow.com/questions/25329302/laravel-error-pdoexception-could-not-find-driver-in-postgresql – kiran gadhvi Jun 08 '16 at 05:18
  • @kirangadhvi it dint help. Btw I'm working on ubuntu,php7,laravel5.2 – s_user Jun 08 '16 at 06:00
  • @s_user is that the same .ini file you checked to see if mysql extension is enabled? – Pitchinnate Jun 08 '16 at 13:41

1 Answers1

2

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.

Paulie-C
  • 1,674
  • 1
  • 13
  • 29
s_user
  • 586
  • 2
  • 8
  • 19