SQLSTATE[HY000] [2002] No such file or directory
While setting up MySQL, I am getting the following error:
Command-line code: testLaravel1 php artisan migrate
SQLSTATE[HY000] [2002] No such file or directory (SQL: select * from information_schema.tables where table_schema
Error:
Illuminate\Database\QueryException
SQLSTATE[HY000] [2002] No such file or directory (SQL: select * from information_schema.tables where table_schema = testLaravel2020 and table_name = migrations and table_type = ‘BASE TABLE’)
at vendor/laravel/framework/src/Illuminate/Database/Connection.php:671
667▕ // If an exception occurs when attempting to run a query, we’ll format the error
668▕ // message to include the bindings with SQL, which will make this exception a
669▕ // lot more helpful to the developer instead of just the database’s errors.
670▕ catch (Exception $e) {
➜ 671▕ throw new QueryException(
672▕ $query, $this->prepareBindings($bindings), $e
673▕ );
674▕ }
675▕
+33 vendor frames
34 artisan:37
Illuminate\Foundation\Console\Kernel::handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
FIX:
This error happen when we use MAMP server in Mac mostly.
So:
I am using Mamp and Laravel 8. My database.php has this line under the MySQL directive:
‘unix_socket’ => env(‘DB_SOCKET’, ”),
The solution was to add the DB_SOCKET option which was missing on the environment file:
DB_SOCKET=/Applications/MAMP/tmp/mysql/mysql.sock
finally, the line should be:
‘unix_socket’ => env(‘DB_SOCKET’, ”), to
hy000, sqlstate hy000, hy000 mysql, mysql hy000, laravel mysql server has gone away, mysql server has gone away laravel, sqlstate hy000 laravel, sql hy000, drupal mysql server has gone away, mysql 1114 the table is full, hy000 odbc, mysql 1114 table is full, 2054 mysql