# 使用 Laradock 的 laravel .env DB 設定 # 沒有 DB local.ERROR: SQLSTATE[HY000] [1049] Unknown database 'default' (SQL: select max(`batch`) as aggregate from `migrations`) {"exception":"[object] (Illuminate\\Database\\QueryException(code: 1049): SQLSTATE[HY000] [1049] Unknown database 'default' (SQL: select max(`batch`) as aggregate from `migrations`) at /var/www/vendor/laravel/framework/src/Illuminate/Database/Connection.php:678) 代表沒有資料庫要自己去建立一個 # DB_HOST 設定與帳號密碼 在使用 laradock 的時候碰到 local.ERROR: SQLSTATE[HY000] [2002] No such file or directory (SQL: select * from information_schema.tables where table_schema = default and table_name = migrations and table_type = 'BASE TABLE') {"exception":"[object] (Illuminate\\Database\\QueryException(code: 2002): SQLSTATE[HY000] [2002] No such file or directory (SQL: select * from information_schema.tables where table_schema = default and table_name = migrations and table_type = 'BASE TABLE') at /var/www/vendor/laravel/framework/src/Illuminate/Database/Connection.php:678) 發現 `DB_HOST` 是用 mysql 而非 127.0.0.1 或 locahost,帳號密碼的部分則是用 laradock 預設的 # 原本與修改後 ```php= // laravel .env // 原本 // laravel .env DB_CONNECTION=mysql DB_HOST=127.0.0.1 DB_PORT=3306 DB_DATABASE=homestead DB_USERNAME=xxxx DB_PASSWORD=xxxx // 修改後 DB_CONNECTION=mysql DB_HOST=mysql (修改) DB_PORT=3306 DB_DATABASE=default DB_USERNAME=xxxx DB_PASSWORD=xxxx ``` {%hackmd BJrTq20hE %} ###### tags: `Laravel` `Docker` `db` `setting` `設定` `docker compose` `2022` `tips` `env`
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up