current position:Home>When initializing the database, an error is reported and the solution is solved

When initializing the database, an error is reported and the solution is solved

2022-01-26 22:06:04 CSDN Q & A

Illuminate\Database\QueryException : SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'user_addresses' already exists (SQL: create table user_addresses (id int unsigned not null auto_increment primary key, user_user_id int not null default '0' comment ' user name
id', name varchar(32) not null default '' comment ' The recipient ', tel varchar(32) not null default '' comment ' contact number ', area varchar(32) not null default '' comment ' The region ', detail varchar(255) not null default '' comment ' Detailed address ', created_at timestamp null, updated_at timestamp null) default character set utf8 collate 'utf8_unicode_ci')

at D:\myphp_www\PHPTutorial\WWW\web\vendor\laravel\framework\src\Illuminate\Database\Connection.php:664
660| // If an exception occurs when attempting to run a query, we'll format the error
661| // message to include the bindings with SQL, which will make this exception a
662| // lot more helpful to the developer instead of just the database's errors.
663| catch (Exception $e) {

664| throw new QueryException(
665| $query, $this->prepareBindings($bindings), $e
666| );
667| }
668|

Exception trace:

1 PDOException::("SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'user_addresses' already exists")
D:\myphp_www\PHPTutorial\WWW\web\vendor\laravel\framework\src\Illuminate\Database\Connection.php:458

2 PDOStatement::execute()
D:\myphp_www\PHPTutorial\WWW\web\vendor\laravel\framework\src\Illuminate\Database\Connection.php:458

Please use the argument -v to see more details.

img




Refer to the answer 1:

1、 surface user_addresses Already exist , Clear the database tables , Perform the data migration again .
2、 Or see if there are two creation user_addresses Migration file for table




Refer to the answer 2:

copyright notice
author[CSDN Q & A],Please bring the original link to reprint, thank you.
https://en.cdmana.com/2022/01/202201262206023837.html

Random recommended