Postingan lainnya
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
2 Jawaban:
<div>arti errornya database "stack" tidak diketahui.<br>Berarti kamu belum membuat database dengan nama stack tersebut</div>
<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="{"contentType":"image/png","filename":"image_2021-10-26_194934.png","filesize":11274,"height":157,"url":"https://i.ibb.co/6FhvptK/image-2021-10-26-194934.png","width":355}" data-trix-content-type="image/png" data-trix-attributes="{"presentation":"gallery"}" 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>