我安裝并打開了 XAMPP,這就是我訪問 phpmyadmin 頁面的方式。我在 phpmyadmin 中創建了一個名為“firstdb”的數據庫。我還在本地存儲的 laravel 文件中創建了 auth。我正在嘗試使用 php artisan migrate 遷移表,但出現以下錯誤。user@Andress-MacBook-Pro admin-panel % php artisan migrate Illuminate\Database\QueryException SQLSTATE[HY000] [2002] Connection refused (SQL: select * from information_schema.tables where table_schema = firstdb and table_name = migrations and table_type = 'BASE TABLE') at vendor/laravel/framework/src/Illuminate/Database/Connection.php:671 667| // If an exception occurs when attempting to run a query, we'll format the error 668| // message to include the bindings with SQL, which will make this exception a 669| // lot more helpful to the developer instead of just the database's errors. 670| catch (Exception $e) { > 671| throw new QueryException( 672| $query, $this->prepareBindings($bindings), $e 673| ); 674| } 675| +37 vendor frames 38 artisan:37 Illuminate\Foundation\Console\Kernel::handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))我到處都看過了,請幫忙。
5 回答

慕仙森
TA貢獻1827條經驗 獲得超8個贊
我注意到命令行輸出中的密碼與 env 文件中的實際密碼有些奇怪。原來我的密碼中有一個數字符號,它被切斷了。
因此,在運行后檢查輸出php artisan migrate
并確保密碼與您環境中的密碼(以及與此相關的所有信息)實際匹配。修復方法是在不匹配時添加引號。
DB_PASSWORD=abcdefghijklmonp5#Q
會成為
DB_PASSWORD='abcdefghijklmonp5#Q'

慕妹3146593
TA貢獻1820條經驗 獲得超9個贊
除了確保您的所有配置都正確使用引號轉義密碼外,我還遇到了類似的問題,以便在 Linux 上進行全新安裝。
SQLSTATE[HY000] [1045] 拒絕用戶 'username'@'localhost' 訪問(使用密碼:YES)
為了解決這個問題,我確保運行composer update
并且我運行了很好的措施npm run dev
然后它能夠毫無問題地遷移。
- 5 回答
- 0 關注
- 355 瀏覽
添加回答
舉報
0/150
提交
取消