0

This is my web.php

<?php

use Illuminate\Support\Facades\Route;

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

Route::get('/register',[App\Http\Controllers\AdminController::class, 'ShowRegister']);
Route::post('/register',[App\Http\Controllers\AdminController::class, 'Register'])->name('register');

.env

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=project
DB_USERNAME=root
DB_PASSWORD=

database.php

'mysql' => [
            'driver' => 'mysql',
            'url' => env('DATABASE_URL'),
            'host' => env('DB_HOST', '127.0.0.1'),
            'port' => env('DB_PORT', '3306'),
            'database' => env('DB_DATABASE', 'project'),
            'username' => env('DB_USERNAME', 'root'),
            'password' => env('DB_PASSWORD', ''),
            'unix_socket' => env('DB_SOCKET', '/Applications/MAMP/tmp/mysql/mysql.sock'),
            'charset' => 'utf8mb4',
            'collation' => 'utf8mb4_unicode_ci',
            'prefix' => '',
            'prefix_indexes' => true,
            'strict' => true,
            'engine' => null,
            'options' => extension_loaded('pdo_mysql') ? array_filter([
                PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
            ]) : [],
        ],

when i try to submit form of register it gives me errors as

Illuminate\Database\QueryException SQLSTATE[HY000] [2002] No such file or directory (SQL: select count(*) as aggregate from admins where email = hello@gmail.com) http://127.0.0.1:8004/register

I searched about it too and came to solution that adding unix_socket fixed issue but unfortunately it doesnot help me either !! what can be issue here ? Help me please !!

Gunaraj Khatri
  • 153
  • 3
  • 13
  • do you use xampp ? – omar esmaeel May 30 '21 at 17:46
  • yes i use xampp – Gunaraj Khatri May 30 '21 at 17:49
  • have you tried that https://stackoverflow.com/questions/1676688/mysql-connection-not-working-2002-no-such-file-or-directory – omar esmaeel May 30 '21 at 17:51
  • i make mysql.default_socket = /path/to/mysql.sock in php.ini and and in database.php ```'unix_socket' => env('DB_SOCKET', '/var/mysql/mysql.sock')``` but still same error – Gunaraj Khatri May 30 '21 at 18:01
  • You say you're using xampp, but the `DB_SOCKET` param in your description seems to indicate you're using MAMP. Are xampp and MAMP the same thing? I think you need to do a sanity check here. Revert all changes you've made to `database.php`. Then confirm you're able to connect to the DB using CLI or a client app. Then confirm the `admins` table exists. Finally, if you're actually using MAMP, then in your `.env` try changing `DB_HOST=127.0.0.1` to `DB_HOST=localhost` – msun May 30 '21 at 19:00

0 Answers0