簡體   English   中英

如何使用 mysql 與本地 laravel 8 風帆安裝

[英]How to use mysql with a local laravel 8 sail installation

我正在學習 Laravel 8 並且我是初學者。 我嘗試通過 Sail 安裝它以利用 Docker。 終端:

curl -s "https://laravel.build/learnlaravel" | bash
cd learnlaravel
./vendor/bin/sail up

現在去 localhost 我看到 Laravel 歡迎頁面,一切正常。

如果我做:

php artisan migrate

我收到此錯誤:

xlf @ MBP16-XLF learnlaravel% php artisan migrate

   Illuminate \ Database \ QueryException

  SQLSTATE [HY000] [2002] No such file or directory (SQL: select * from information_schema.tables where table_schema = learnlaravel 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▕

有人可以用簡單的話向我解釋我做錯了什么或我應該做什么嗎? mySQL 數據庫是否已經在 Docker 上? 我如何登錄以使用 .env 文件的憑據創建和配置它? 謝謝你的理解和支持:)

嘗試

./vendor/bin/sail artisan migrate

代替

php artisan migrate

文檔: https://laravel.com/docs/8.x/artisan#laravel-sail

此外,您可以安裝任何數據庫管理器並使用此憑據連接到您的數據庫以查看和配置它。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM