mengapa saat ingin membuat migration laravel muncul error seperti ini?

C:\xampp\htdocs\modul07>php artisan migrate

   Illuminate\Database\QueryException

  SQLSTATE[HY000] [1049] Unknown database 'stack' (SQL: select * from information_schema.tables where table_schema = stack and table_name = migrations and table_type = 'BASE TABLE')

  at C:\xampp\htdocs\modul07\vendor\laravel\framework\src\Illuminate\Database\Connection.php:703
    699▕         // If an exception occurs when attempting to run a query, we'll format the error
    700▕         // message to include the bindings with SQL, which will make this exception a
    701▕         // lot more helpful to the developer instead of just the database's errors.
    702▕         catch (Exception $e) {
   703▕             throw new QueryException(
    704▕                 $query, $this->prepareBindings($bindings), $e
    705▕             );
    706▕         }
    707▕     }

  1   C:\xampp\htdocs\modul07\vendor\laravel\framework\src\Illuminate\Database\Connectors\Connector.php:70
      PDOException::("SQLSTATE[HY000] [1049] Unknown database 'stack'")

  2   C:\xampp\htdocs\modul07\vendor\laravel\framework\src\Illuminate\Database\Connectors\Connector.php:70
      PDO::__construct("mysql:host=127.0.0.1;port=3306;dbname=stack", "root", "", [])

Cuplikan layar 2021-10-25 010903.pngCuplikan layar 2021-10-25 010950.png

avatar vinaaa
@vinaaa

1 Kontribusi 0 Poin

Diperbarui 2 tahun yang lalu

2 Jawaban:

<div>arti errornya database "stack" tidak diketahui.<br>Berarti kamu belum membuat database dengan nama stack tersebut</div>

avatar hilmanski
@hilmanski

2665 Kontribusi 2131 Poin

Dipost 2 tahun yang lalu

<div>Biasanya ini karna urutan membuat database nya salah. Membuat table database lewat migration itu linear, coba cek file migrationnya. Misal, coba liat gambar ini :<figure data-trix-attachment="{&quot;contentType&quot;:&quot;image/png&quot;,&quot;filename&quot;:&quot;image_2021-10-26_194934.png&quot;,&quot;filesize&quot;:11274,&quot;height&quot;:157,&quot;url&quot;:&quot;https://i.ibb.co/6FhvptK/image-2021-10-26-194934.png&quot;,&quot;width&quot;:355}" data-trix-content-type="image/png" data-trix-attributes="{&quot;presentation&quot;:&quot;gallery&quot;}" class="attachment attachment--preview attachment--png"><img src="https://i.ibb.co/6FhvptK/image-2021-10-26-194934.png" width="355" height="157"><figcaption class="attachment__caption"><span class="attachment__name">image_2021-10-26_194934.png</span></figcaption></figure><br>Disini laravel akan buat table dengan urutan dari atas ke bawah, jadi akan dibuat tabel "users" dulu lalu "password_reset", "failed_job", dst. Ketika misalnya tabel "barang" ada hubungan dengan tabel "kredit" (contohnya foreign key), maka akan error karena tabel kreditnya belum dibuat. Coba cek video ini<br>https://www.youtube.com/watch?v=2s0xgUVPtEg<br>di menit 2:21 solusinya</div>

avatar mteguhawaludin
@mteguhawaludin

3 Kontribusi 1 Poin

Dipost 2 tahun yang lalu

Login untuk ikut Jawaban