我不能运行 Laravel database,错误的信息一直重复
首先,以下我的错误信息:
1)SQLSTATE[42S02]: Base table or view not found: 1146 Table 'forge.settings' doesn't exist (SQL: select * from
settingswhere
auto_load_disabledis null)
2)SQLSTATE[42S02]: Base table or view not found: 1146 Table 'forge.settings' doesn't exist
不管是任何的command我都试过了:php artisan serve
, php artisan migrate
,php artisan migrate:fresh
它都会显示以上的1)和 2)的错误信息。 以下是我的代码:
在.env file
APP_ENV=local
APP_KEY=
APP_DEBUG=true
APP_URL=http://localhost
LOG_CHANNEL=stack
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=forge
DB_USERNAME=root
DB_PASSWORD=
没有APP_KEY 因为连`php artisan key:generate
它也显示1)2)的错误。
在database.php:
'mysql' => [
'driver' => 'mysql',
'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' => '',
'strict' => true,
'modes' => [
'STRICT_TRANS_TABLES',
'NO_ZERO_IN_DATE',
'NO_ZERO_DATE',
'ERROR_FOR_DIVISION_BY_ZERO',
'NO_AUTO_CREATE_USER',
'NO_ENGINE_SUBSTITUTION'
],
'engine' => 'InnoDB',
],`
我用的是xampp server, 我已经在上面创建了‘forge’的database。
我的migration file: create_settings_table:
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateSettingsTable extends Migration
{
public function up()
{
Schema::create('settings', function (Blueprint $table) {
$table->increments('id');
$table->string('option_key');
$table->longText('option_value')->nullable();
$table->boolean('auto_load_disabled')->nullable();
});
}
public function down()
{
Schema::dropIfExists('settings');
}
}
想请教各位朋友还有其他办法或者提示吗?
推荐文章: