"[PDOException] SQLSTATE[HY000] [2002] No such file or directory" when you migrate your database with mysql server in laravel
This problem occurs when you have installed your laravel project perfectly and wanted to migrate or execute the command 'php artisan migrate', then your terminal is showing this problem. There so many solutions on the web I tried and the only solutions are given below:
Step 1: go to config/database.php file and open it and change just mysql array as below-
'mysql' => [
'driver' => 'mysql',
'host' => '127.0.0.1',
'port' => '8889',
'database' => 'multiauth',(your database name)
'username' => 'root',(your user name)
'password' => 'root',(your password)
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
],
Step 2: change your .env file as below-
DB_HOST=127.0.0.1
DB_DATABASE=multiauth(your database name)
DB_USERNAME=root(your user name)
DB_PASSWORD=root(your password)
Now run or execute the command 'php artisan migrate' and be happy.
Step 1: go to config/database.php file and open it and change just mysql array as below-
'mysql' => [
'driver' => 'mysql',
'host' => '127.0.0.1',
'port' => '8889',
'database' => 'multiauth',(your database name)
'username' => 'root',(your user name)
'password' => 'root',(your password)
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
],
Step 2: change your .env file as below-
DB_HOST=127.0.0.1
DB_DATABASE=multiauth(your database name)
DB_USERNAME=root(your user name)
DB_PASSWORD=root(your password)
Now run or execute the command 'php artisan migrate' and be happy.
great job
ReplyDeletethanks dost
Delete