0

homestead version: 9.2.0 vagrant version: 2.2.7 php version: 7.2.21 mysql version: 8.0.18

I created a new laravel project. I created a database called tickets. I've added the third party code from https://github.com/creativetimofficial/material-dashboard-laravel. When I get to step where you run "php artisan migrate --seed" I'm getting two different errors depedning on how I set db port in .env file.

Here's a picture of my db users and their hosts.

enter image description here

when DB_HOST=127.0.0.1 and I run the artisan migrate I get an error saying Connection refused. I only tried using 127.0.0.1 because I saw online people saying to use this instead of localhost. Since the connection is refused I have a feeling this isn't correct.

When DB_HOST=localhost and I run artisan migrate I get an error saying

No such file or directory (SQL: select * from information_schema.tables where table_schema = tickets and table_name = migrations and table_type = 'BASE TABLE') {"exception":"[object] (Illuminate\\Database\\QueryException(code: 2002): SQLSTATE[HY000] [2002] No such file or directory (SQL: select * from information_schema.tables where table_schema = tickets and table_name = migrations and table_type = 'BASE TABLE') at /Applications/MAMP/htdocs/ticket-dashboard/vendor/laravel/framework/src/Illuminate/Database/Connection.php:669)

Questions: 1) should I be using the IP instead of localhost and if so why do I get connection refused with using the IP? 2) If using localhost is fine, what needs to be fixed to bypass this error?

I've been testing everything I can find online to help, but this is the closest I've gotten. Any advice or ideas would be greatly appreciated

Derek Joseph Olson
  • 738
  • 1
  • 7
  • 22
  • 1
    https://stackoverflow.com/questions/1676688/mysql-connection-not-working-2002-no-such-file-or-directory might be of some help – aynber Feb 26 '20 at 16:51
  • In brief, `localhost` uses a socket connection while `127.0.0.1` uses a network connection. By default, for security reasons, MySQL has networking disabled. To use the socket, your PHP install needs to be configured with the proper location of the MySQL socket file. I would have expected a package like MAMP to set that up for you; isn't that the whole point of it? – miken32 Feb 26 '20 at 17:24
  • If you're using Homestead, you need to run ```php artisan migrate``` from within your virtual machine. Like run ```vagrant ssh``` and migrate to the folder of your project from within vagrant and then run your migration. – Abdellah Ramadan Feb 26 '20 at 17:36

0 Answers0