0

I'm using PHP 7.1, MySQL 5.7, and Laravel 5.7.12. And on a Mac.

I'm new to Laravel. I'm building my application on a remote server (a Cloudways Server). I know most people build their project locally and then deploy their application onto a remote server, but I'm just building my application on a live remote server and I'm using SFTP.

I've configured my .env file to reflect my server's connection details.

When I try to run php artisan migrate I get this error:

Illuminate\Database\QueryException  : SQLSTATE[HY000] [2002] No such file or directory (SQL: select * from information_schema.tables where table_schema = ********* and table_name = migrations)

  at /Users/newadmin/Documents/Sites/Quipper/vendor/laravel/framework/src/Illuminate/Database/Connection.php:664
    660|         // If an exception occurs when attempting to run a query, we'll format the error
    661|         // message to include the bindings with SQL, which will make this exception a
    662|         // lot more helpful to the developer instead of just the database's errors.
    663|         catch (Exception $e) {
  > 664|             throw new QueryException(
    665|                 $query, $this->prepareBindings($bindings), $e
    666|             );
    667|         }
    668| 

  Exception trace:

  1   PDOException::("SQLSTATE[HY000] [2002] No such file or directory")
      /Users/newadmin/Documents/Sites/Quipper/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php:70

  2   PDO::__construct("mysql:host=localhost;dbname=*********", "*********", "**********", [])

    /Users/newadmin/Documents/Sites/Quipper/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php:70

Above I've placed ********** where my database name, username and password go, I guess just for security reasons.

I think it's worth noting on that second exception trace it says "mysql:host=localhost;", when in my .env file I have put in my DB_HOST address, which is a remote server address. So it shouldn't be saying localhost. That seems like it could be part of the problem?

Any help would be greatly appreciated!

I've already tried running in my terminal:

php artisan cache:clear php artisan config:cache

And that didn't work.

Trevor
  • 3
  • 1
  • Possible duplicate of [MySQL connection not working: 2002 No such file or directory](https://stackoverflow.com/questions/1676688/mysql-connection-not-working-2002-no-such-file-or-directory) – dparoli Aug 29 '19 at 15:45

1 Answers1

0

From the log file, look at the path to the PHP script

/Users/newadmin/Documents/Sites/Quipper

This is in your local Mac or MacBook computer, which means that you need to SSH into your Cloudways server and then run the php artisan migrate command

By SSH I mean running something like

ssh cloudways_user@server_IP_ADDRESS
cd Quipper && php artisan migrate
Salim Djerbouh
  • 10,719
  • 6
  • 29
  • 61
  • Thank you for the answer. After trying to figure it out for a long time, it turned out that I needed to whitelist my computer's IP address for my host (Cloudways) to let me interact with the database. I appreciate your answer and time though! – Trevor Sep 29 '19 at 19:26