0

I'm using Laravel Framework 8.20.1 & XAMPP For MySQL Database on MAC and when i run this command: php artisan migrate it display an error message not sure why ?

.env:

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

Error:

Illuminate\Database\QueryException 

  SQLSTATE[HY000] [2002] No such file or directory (SQL: select * from information_schema.tables where table_schema = atamana_db and table_name = migrations and table_type = 'BASE TABLE')

  at vendor/laravel/framework/src/Illuminate/Database/Connection.php:678
    674▕         // If an exception occurs when attempting to run a query, we'll format the error
    675▕         // message to include the bindings with SQL, which will make this exception a
    676▕         // lot more helpful to the developer instead of just the database's errors.
    677▕         catch (Exception $e) {
  ➜ 678▕             throw new QueryException(
    679▕                 $query, $this->prepareBindings($bindings), $e
    680▕             );
    681▕         }
    682▕ 

      +33 vendor frames 
  34  artisan:37
      Illuminate\Foundation\Console\Kernel::handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
  • Have a look at this answer: https://stackoverflow.com/a/20733001/7181149 – Ahmad Karimi Jan 02 '21 at 14:27
  • does ```php artisan migrate:fresh``` work? be careful - this does a rollback for all your migrations and applies them again – Felix Geenen Jan 02 '21 at 15:47
  • Already try both solutions before but it did not work at all. This is a fresh install project for testing so i do not mind to rollback anything –  Jan 02 '21 at 18:52
  • I Have install and configure MySQL Base on This Article but still the same problem https://medium.com/macoclock/mysql-on-mac-getting-started-cecb65b78e –  Jan 03 '21 at 18:48

1 Answers1

0

I would strongly recommend using Homebrew to set up MySQL instead.

Visit https://brew.sh/

Open your terminal and run the command on the brew website to install it.

Then install mysql using

brew install mysql

Start MySQL by running

brew services start mysql

Create your database by running

mysql -u root -p
CREATE DATABASE atamana_db;

Since PHP doesn't yet understand caching_sha2_password, try mysql_native_password use This Command:

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';

Then hit Control + C to exit MySQL

Try running your migration again.