'laravel php artisan ERROR
It's the first time I using laravel to generate PHP program, at first I create a blog by composer, and in this blog, I can run php artisan.
However, I download a laravel project from internet, I cannot run artisan and give me the ERROR result as follow.
[Illuminate\Database\QueryException]
SQLSTATE[HY000] [2002] No such file or directory (SQL: select count(*) as
aggregate from plugins where name = Ldap and status = 1)
[Doctrine\DBAL\Driver\PDOException] SQLSTATE[HY000] [2002] No such file or directory
[PDOException] SQL STATE [HY000] [2002] No such file or directory
and the mySQL serve of my XAMPP shutting down at the same time, what confuse me is I can visit this project via vitrual host.
I think maybe there are some mistake about the root right of mySQL, but I don't know how to deal with.
Solution 1:[1]
Try to install laravel using cmd(composer) by entering command "composer create-project --prefer-dist laravel/laravel blog" this will create a folder of blog in the current directory where you executed the command. It will take some time to download and install so wait upto 5 mints. After that run command "php artisan serve" and then you can start using laravel by visiting localhost:8000
Solution 2:[2]
For first time running, check your database information in .env file. Make sure it connected to correct database.
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=yourdbname
DB_USERNAME=dbuser
DB_PASSWORD=dbpass
If needed, run composer install or update
composer install
Then run key generate
php artisan key:generate
Then run migration
php artisan migrate:fresh
If the project have seeder, use:
php artisan migrate:fresh --seed
Then serve to run the localhost server
php artisan serve
If you are developing project using Laravel, I would suggest you to use Laragon instead of XAMPP
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Muhammad Zeeshan |
| Solution 2 | HaHa |
