我正在嘗試按照本教程進行遷移https://www.youtube.com/watch?v=074AQVmvvdg&list=PL4cUxeGkcC9hL6aCFKyagrT1RCfVN4w2Q&index=13
我認為該教程可能已過時,因為當我輸入時出現php artisan migrate;此錯誤:
Illuminate\Database\QueryException
could not find driver (SQL: select * from information_schema.tables where table_schema = pizzahouse and table_name = migrations and table_type = 'BASE TABLE')
at C:\Users\jonke\Documents\laravel\pizzahouse\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:\Users\jonke\Documents\laravel\pizzahouse\vendor\laravel\framework\src\Illuminate\Database\Connectors\Connector.php:70
PDOException::("could not find driver")
2 C:\Users\jonke\Documents\laravel\pizzahouse\vendor\laravel\framework\src\Illuminate\Database\Connectors\Connector.php:70
PDO::__construct()
我已閱讀視頻的評論,在那里我找到了較早錯誤的解決方案。我在此頁面上嘗試了以下建議:https : //github.com/laravel/framework/issues/24711這似乎很有希望但沒有樂趣。
我在這個網站上找到了描述不同原因的相同錯誤訊息的頁面。一個看起來很有希望,但 vscode 不喜歡 sudo apt-get 位。(我已經失去了鏈接,抱歉)。
這個有一個類似的標題但不好:Migration in Laravel 5.6 - 找不到驅動程式
我也嘗試按照官方檔案:https : //laravel.com/docs/8.x/migrations
我如何能夠在 vscode 的命令列中創建資料庫但不運行遷移?我不明白!我已經在圈子里點擊了幾天了,有人可以幫我嗎?
謝謝
uj5u.com熱心網友回復:
這是c:\php7/php.ini- 需要修改一行 - 取消注釋此行:
extension=pdo_mysql
答案在這里找到:https : //stackoverflow.com/a/25137901/16714187
uj5u.com熱心網友回復:
添加了 JonKemm 解決方案
這是c:\php7/php.ini- 需要修改一行 - 取消注釋這一行:extension=pdo_mysql 答案在這里找到:https ://stackoverflow.com/a/25137901/16714187
如果您的問題沒有解決任何其他情況,請嘗試進一步
您必須添加驅動程式連接讀取代碼。你可以在
config->database.php
'mysql' => [
'driver' => 'mysql',
'url' => env('DATABASE_URL'),
'host' => env('DB_HOST', '127.0.0.1'),
'port' => env('DB_PORT', '3306'),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'unix_socket' => env('DB_SOCKET', ''),
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci',
'prefix' => '',
'prefix_indexes' => true,
'strict' => true,
'engine' => null,
'options' => extension_loaded('pdo_mysql') ? array_filter([
PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
]) : [],
],
如果你沒有在黑白中找到這個
'connections' => [
...
],
以上版本復制自 Laravel Framework 6.20.30
如果您從舊版 Laravel 的這些代碼中遺漏了某些內容,請嘗試比較或添加一些代碼。
如果您在那里沒有找到 mysql 代碼,請復制我的代碼并粘貼到您的檔案中,如果您在下面發現任何錯誤注釋。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/325967.html
