As we execute artisan commands, we sometimes encounter these errors. If we’ll not take note of these, we might waste our time looking for solutions. That’s why, I have listed down some of these for you who might be encountering such problems.
1. General error: 1813
SQLSTATE[HY000]: General error: 1813 Tablespace for table '`lara55db`.`migr
ations`' exists. Please DISCARD the tablespace before IMPORT.
Drop the database and create a new one. If you cannot drop it on your phpmyadmin, you have to delete it manually inside the
2. 1071 Specified key was too long; max key length is 767 bytes
SQLSTATE: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes (SQL: alter table users add unique users_email_unique(email))
SQLSTATE: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes
If you are running a version of MySQL older than the 5.7.7 release or MariaDB older than the 10.2.2 release, you may need to manually configure the default string length generated by migrations in order for MySQL to create indexes for them.
App>>Providers>>AppServiceProvider.php and add the script below.
public function boot()
3. Migrating of tables
When you see this error after you executed
php artisan migrate,
SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'users' alre
ady exists (SQL: create table `users` (`id` int unsigned not null auto_incr
ement primary key, `username` varchar(255) not null, `email` varchar(255) n
ot null, `password` varchar(255) not null, `created_at` timestamp default 0
not null, `updated_at` timestamp default 0 not null) default character set
utf8 collate utf8_unicode_ci)
you may try these,
Option 1: From your terminal, execute the command below.
php artisan migrate:rollback
Option 2: Go to your database, drop the migrations and then execute
php artisan migrate.
If you’ve encountered errors which have not been written, please comment below for future reference.