剛剛做了一個新的 Laravel 專案并嘗試遷移表,我得到了這個:
SQLSTATE[HY000] [2002] 沒有這樣的檔案或目錄(SQL: select * from information_schema.tables where table_schema = SugarDaddy and table_name = migrations and table_type = 'BASE TABLE')
我嘗試清除快取、路由、配置,并將 DBHOST 從 127.0.0.1 更改為 localhost 并回傳,正如我在幾篇文章中看到的那樣,但沒有任何效果。我將在此處留下遷移和資料庫的 ss。
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateUsersTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('users', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('email')->unique();
$table->timestamp('email_verified_at')->nullable();
$table->string('password');
$table->rememberToken();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('users');
}
}
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=sugarDaddy
DB_USERNAME=root
DB_PASSWORD=
![SQLSTATE[HY000] [2002] 當我嘗試 php artisan migrate 時沒有這樣的檔案或目錄](https://img.uj5u.com/2021/10/26/37581096374e4bc697e0b5bd1aa5988c.jpg)
uj5u.com熱心網友回復:
我可以從螢屏截圖中看到您的 phpMyAdmin 正在連接到8889埠的資料庫,您的envhas DB_PORT=3306,更改為DB_PORT=8889.
評論區總結:
Dan 正在使用 MAMP,因此 mysql 連接的配置應包含(對于默認 MAMP 設定):
DB_HOST=localhost
DB_PORT=8889
DB_USERNAME=root
DB_PASSWORD=root
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/336970.html
標籤:php 拉拉维尔 phpmyadmin 数据库迁移 马普
