Reputation: 634
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
Upvotes: 1
Views: 3473
Reputation: 634
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.
Upvotes: 0
Reputation: 101
[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
Upvotes: 0
Reputation: 101
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"
Upvotes: 1
Reputation: 273
At the beginning of this file bootstrap/autoload.php yuo can try this file
Upvotes: 0