Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Connection refused SQL: select * from information_schema.tables where table_schema = firstdb and table_name = migrations and table_type = 'BASE TABLE

I have XAMPP installed and turned on which is how I access my phpmyadmin page. I have created a database in phpmyadmin called "firstdb".

I have also created auth in laravel files stored locally. I am trying to migrate tables using php artisan migrate and I am getting the error below.

user@Andress-MacBook-Pro admin-panel % php artisan migrate

   Illuminate\Database\QueryException 

  SQLSTATE[HY000] [2002] Connection refused (SQL: select * from information_schema.tables where table_schema = firstdb 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| 

      +37 vendor frames 
  38  artisan:37
      Illuminate\Foundation\Console\Kernel::handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

I have looked everywhere, please help.

like image 402
Andres Osorio Avatar asked Apr 16 '20 03:04

Andres Osorio


2 Answers

It could be the wrong mysql port number in your .env file. Check your .env file and make sure the port number matches the same one mysql is using.

like image 200
Nelson Katale Avatar answered Nov 12 '22 12:11

Nelson Katale


I noticed something weird regarding the password that was in the command line output vs what was actually in the env file. Turned out I had a number sign in my password and it was getting cut off.

So check the output after you run php artisan migrate and make sure that the password actually matches the password in your env (and all information for that matter). The fix is to just add quotes if there is a mismatch.

DB_PASSWORD=abcdefghijklmonp5#Q

would become

DB_PASSWORD='abcdefghijklmonp5#Q'

like image 39
Richard Kersey Avatar answered Nov 12 '22 12:11

Richard Kersey