简体   繁体   中英

SQLSTATE[HY000] [2002] No such file or directory (SQL: select * from `jobs`)

Error Picture:

在此处输入图像描述

These are all my errors that I get but I have 63 frames erros I'm not going to list. Since going through all would be to much I guess.

A fix would be good.

My files https://1drv.ms/u/s?AnPb5n9nCL2ipyH_Wu61GVkT-Xk?e=TGpkoM ///

  // run the SQL against the PDO connection. Then we can calculate the time it
    // took to execute and log the query SQL, bindings and time in our memory.
    try {
        $result = $callback($query, $bindings);
    }

    // If an exception occurs when attempting to run a query, we'll format the error
    // message to include the bindings with SQL, which will make this exception a
    // lot more helpful to the developer instead of just the database's errors.
    catch (Exception $e) {
        throw new QueryException(
            $query, $this->prepareBindings($bindings), $e
        );
    }

    return $result;
}

/**
 * Log a query in the connection's query log.
 *
 * @param  string  $query
 * @param  array  $bindings

///

Check your database first, did that table exist? it seems like your table (jobs) isn't created from your database. try to create a new migration file since laravel support create a new table from a file.

php artisan make:migration (your migration name)

Then go to that file to edit your table schema Laravel Migration Docs

If you created that database on local machine and it works, try to export your local database to public database.

Or last option, check your Model File. in Laravel 8+, All models File goes to App\Model Directory. So it must be:

use App\Models\Job;

Try running php artisan migrate . If that fails, check your database credentials in .env :

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

check to see if your mysql.sock file isn't found.

You can restart the MySQL server and see, whether this fixes it or you add/edit this line to your php.ini:

     pdo_mysql.default_socket="/var/lib/mysql/mysql.sock"

Just check the path to the mysql.sock and adjust it accordingly - and you have to restart Apache after making changes to php.ini

or do the following:

    sudo mkdir /var/mysql
    cd /var/mysql

sudo ln -s /var/mysql/mysql.sock i'm not really familiar with MACs so there might be little changes necessary to this

Change DB_HOST value in your.env from localhost to 127.0.0.1

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM