Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

shahr's avatar
Level 10

SQLSTATE[42000]: Syntax error or access violation

I am using XAMPP and MySQL version. I'm trying to migrate Laravel media libraries package:

DATABASE

public function up()
{
    Schema::create('users', function (Blueprint $table) {
        $table->bigIncrements('id');
        $table->string('first_name');
        $table->string('last_name');
        $table->string('mobile')->unsigned();
        $table->string('telephone');
        $table->string('email')->unique();
        $table->timestamp('email_verified_at')->nullable();
        $table->string('password');
        $table->string('image')->nullable();
        $table->rememberToken();
        $table->timestamps();
    });
}
0 likes
3 replies
shahr's avatar
Level 10

I get this error.

Illuminate\Database\QueryException : SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that cor responds to your MariaDB server version for the right syntax to use near 'unsigned not null, telephone varchar(191) not null, email varchar(191) not n' at l ine 1 (SQL: create table users (id bigint unsigned not null auto_increment primary key, first_name varchar(191) not null, last_name varchar(191) not nul l, mobile varchar(191) unsigned not null, telephone varchar(191) not null, email varchar(191) not null, email_verified_at timestamp null, password var char(191) not null, image varchar(191) null, remember_token varchar(100) null, created_at timestamp null, updated_at timestamp null) default character s et utf8mb4 collate 'utf8mb4_unicode_ci')

bobbybouwmann's avatar

What is the error you get? Does the database already exist?

Try running this once php artisan migrate:fresh

blisssan's avatar

Pls double check your mobile column its string and unsigned. Thats where it throws error unsigned not null. I believe in MySQL only integers can be unsigned.

Please or to participate in this conversation.