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

mrad's avatar
Level 1

php artisan migrate fails with error 1071

I am testing spark on MAMP. After I ran the installer and created the database, I ran

php artisan migrate This fails with the following error: [Illuminate\Database\QueryException] SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes (SQL: alter table announcements add pri mary key announcements_id_primary(id))

[PDOException] SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes

How can I prevent this? I created the database in phpMyAdmin with these commands:

CREATE USER 'homestead'@'%' IDENTIFIED WITH mysql_native_password;GRANT ALL PRIVILEGES ON . TO 'homestead'@'%' REQUIRE NONE WITH GRANT OPTION MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0;SET PASSWORD FOR 'homestead'@'%' = '*'; CREATE DATABASE IF NOT EXISTS homestead;GRANT ALL PRIVILEGES ON homestead. TO 'homestead'@'%';GRANT ALL PRIVILEGES ON homestead\_%. TO 'homestead'@'%';

0 likes
1 reply

Please or to participate in this conversation.