I get this error when I want to php artisan migrate. The error message is as follows
Illuminate\Database\QueryExceptionSQLSTATE[42S01]: Base table or view already exists: 1050 Table 'users' already exists (SQL: create table
users(idbigint unsigned not null auto_increment primary key,namevarchar(255) not null,email_verified_attimestamp null,passwordvarchar(255) not null,remember_tokenvarchar(100) null,created_attimestamp null,updated_attimestamp null) default character set utf8mb4 collate 'utf8mb4_unicode_ci')at C:\composer\blog\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▕
1
C:\composer\blog\vendor\laravel\framework\src\Illuminate\Database\Connection.php:464 PDOException::("SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'users' already exists")2
C:\composer\blog\vendor\laravel\framework\src\Illuminate\Database\Connection.php:464 PDOStatement::execute()
And Database settings are as follows. The settings in the Database.php file are as follows
'mysql' => [
'driver' => 'mysql',
'url' => env('DATABASE_URL'),
'host' => env('DB_HOST', 'localhost'),
'port' => env('DB_PORT', '3306'),
'database' => env('DB_DATABASE', 'laravel'),
'username' => env('DB_USERNAME', 'root'),
'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'),
]) : [],
],
The settings in the .env file are as follows
APP_NAME=Laravel
APP_ENV=local
APP_KEY=base64:sBKduFaKhOJdg7/A1U4IzAUnj3yLLcjngjmMvEoWl94=
APP_DEBUG=true
APP_URL=http://localhost
LOG_CHANNEL=stack
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=laravel
DB_USERNAME=root
DB_PASSWORD=
Note: I use mysql for wampserver.
1050 Table 'users' already exists"can you see error it is sayingusersalready exites so can't create again or you can tryphp artisan migrate:fresh