Connect with us

Problem SQLSTATE[42000]: Syntax error or access violation:

migrating error

Tips & Trik

Problem SQLSTATE[42000]: Syntax error or access violation:

Bagi teman-teman yang memiliki masalah seputar laravel, khususnya dalam hal migrate terkadang muncul error seperti berikut di bawah ini:

SQLSTATE[42S01]: Base table or view already exists: 1050 Table ‘users’ already exists (SQL: create table `users` (`id` bigint unsigned not null auto_increment primary key, `name` varchar(255) not null, `email` varchar(255) not null, `email_verified_at` timestamp null, `password` varchar(255) not null, `remember_token` varchar(100) null, `created_at` timestamp null,
`updated_at` timestamp null) default character set utf8mb4 collate ‘utf8mb4_unicode_ci’)

at C:\xampp\htdocs\voyager\example-app\vendor\laravel\framework\src\Illuminate\Database\Connection.php:712
708▕ // If an exception occurs when attempting to run a query, we’ll format the error
709▕ // message to include the bindings with SQL, which will make this exception a
710▕ // lot more helpful to the developer instead of just the database’s errors.
711▕ catch (Exception $e) {
➜ 712▕ throw new QueryException(
713▕ $query, $this->prepareBindings($bindings), $e
714▕ );
715▕ }
716▕ }

716▕ }

1 C:\xampp\htdocs\voyager\example-app\vendor\doctrine\dbal\lib\Doctrine\DBAL\Driver\PDO\Exception.php:18
Doctrine\DBAL\Driver\PDO\Exception::(“SQLSTATE[42S01]: Base table or view already exists: 1050 Table ‘users’ already exists”)

2 C:\xampp\htdocs\voyager\example-app\vendor\doctrine\dbal\lib\Doctrine\DBAL\Driver\PDOStatement.php:119
Doctrine\DBAL\Driver\PDO\Exception::new(Object(PDOException))

 

Jangan khawatir, silahkan lakukan hal berikut ini :

  1. Silahkan buka folder laravel teman-teman, lalu masuk ke folder app/Providers/ dan buka file AppServiceProvider.php .
  2. Setelah itu, silahkan masukkan kode Schema::defaultStringLength(191); pada public function boot(), sehingga menjadi seperti dibawah ini:

public function boot() {

Schema::defaultStringLength(191);

}

3. Selanjutnya, jangan lupa untuk menambahkan :

use Illuminate\Support\Facades\Schema;

4. Lalu SAVE. Selamat mencoba

Continue Reading
You may also like...

CEO Republikmurah.com

Click to comment

Leave a Reply

Your email address will not be published. Required fields are marked *

More in Tips & Trik

Advertisement
Advertisement
Advertisement
To Top
Hubungi Kami