1

I want to use 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 following error:

[PDOException] could not find driver 

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

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

So what is the issue and how to solve it ? I was told to check for php.ini locaton. I did,and 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 ??

I have been through the links below in order to find answer : Set path to php.ini

How is php.ini related to php.ini-development and php.ini-production?

Overriding global php.ini file

Community
  • 1
  • 1
s_user
  • 586
  • 2
  • 8
  • 19

4 Answers4

1

Yor are not define port in your .env file Db_PORT=3306

  DB_CONNECTION=mysql
  DB_HOST=127.0.0.1
  DB_PORT=3306
  DB_DATABASE=people
  DB_USERNAME=pftest
  DB_PASSWORD="pftest_2016#9"
  • check this link (http://www.johnshipp.com/php-artisan-migrate-laravel-5-pdoexception-sqlstatehy000-2002-no-such-file-or-directory-on-a-mac-using-mamp/) – Ayaz ahmed khan Jun 08 '16 at 06:40
0

At the beginning of this file bootstrap/autoload.php yuo can try this file

Abdul Hameed
  • 263
  • 4
  • 19
0
     [PDOException]  SQLSTATE[HY000] [2002] Connection refused

The error message indicates that a MySQL connection via socket is tried (which is not supported).

In the context of Laravel (artisan), you probably want to use a different / the correct environment.

Eg: php artisan migrate --env=production (or whatever environment). See here.https://laravel.com/docs/5.2/artisan#usage

  • which env is advised to be used? I'm not using laravel-homestead. And I have tried local,dev,production env all of them throw same error. – s_user Jun 08 '16 at 06:24
0

Answer is addition to Ayaz's answer,

In .env file, set

APP_ENV=local DB_PORT=3306

and the do php artisian migrate --env="local"

Same is valid for development,production environment.

s_user
  • 586
  • 2
  • 8
  • 19