question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

MySQL/MariaDB - ER_TOO_LONG_KEY: Specified key was too long; max key length is 767 bytes

See original GitHub issue

Hi,

When I try to configure pigallery to use the MySQL instance on my raspberry I get: Error: Error while saving database settings: QueryFailedError: ER_TOO_LONG_KEY: Specified key was too long; max key length is 767 bytes

When I check the output of the process I get:

9/9/2019, 3:17:28 PM[INFO] Updating database scheme
9/9/2019, 3:17:28 PM[WARN] Handled error:
ErrorDTO {
  code: 13,
  message: 'Error while saving database settings: QueryFailedError: ER_TOO_LONG_KEY: Specified key was too long; max key length is 767 bytes',
  details: 
   { QueryFailedError: ER_TOO_LONG_KEY: Specified key was too long; max key length is 767 bytes
       at QueryFailedError.Error (native)
       at new QueryFailedError (/var/www/pigallery/node_modules/typeorm/error/QueryFailedError.js:11:28)
       at Query.<anonymous> (/var/www/pigallery/node_modules/typeorm/driver/mysql/MysqlQueryRunner.js:169:45)
       at Query.<anonymous> (/var/www/pigallery/node_modules/mysql/lib/Connection.js:525:10)
       at Query._callback (/var/www/pigallery/node_modules/mysql/lib/Connection.js:491:16)
       at Query.Sequence.end (/var/www/pigallery/node_modules/mysql/lib/protocol/sequences/Sequence.js:83:24)
       at Query.ErrorPacket (/var/www/pigallery/node_modules/mysql/lib/protocol/sequences/Query.js:90:8)
       at Protocol._parsePacket (/var/www/pigallery/node_modules/mysql/lib/protocol/Protocol.js:291:23)
       at Parser._parsePacket (/var/www/pigallery/node_modules/mysql/lib/protocol/Parser.js:433:10)
       at Parser.write (/var/www/pigallery/node_modules/mysql/lib/protocol/Parser.js:43:10)
     message: 'ER_TOO_LONG_KEY: Specified key was too long; max key length is 767 bytes',
     code: 'ER_TOO_LONG_KEY',
     errno: 1071,
     sqlMessage: 'Specified key was too long; max key length is 767 bytes',
     sqlState: '42000',
     index: 0,
     sql: 'CREATE TABLE `user_entity` (`id` int NOT NULL AUTO_INCREMENT, `name` varchar(255) NOT NULL, `password` varchar(255) NOT NULL, `role` smallint NOT NULL, `permissions` text NULL, UNIQUE INDEX `IDX_3fe76ecf0f0ef036ff981e9f67` (`name`), PRIMARY KEY (`id`)) ENGINE=InnoDB',
     name: 'QueryFailedError',
     query: 'CREATE TABLE `user_entity` (`id` int NOT NULL AUTO_INCREMENT, `name` varchar(255) NOT NULL, `password` varchar(255) NOT NULL, `role` smallint NOT NULL, `permissions` text NULL, UNIQUE INDEX `IDX_3fe76ecf0f0ef036ff981e9f67` (`name`), PRIMARY KEY (`id`)) ENGINE=InnoDB',
     parameters: [] } }

I’m using:

raspberry: Pi 3 Model B
OS: Linux 4.14.78-4-osmc
mysql  Ver 15.1 Distrib 10.1.38-MariaDB, for debian-linux-gnueabihf (armv7l) using readline 5.2
npm -version: 6.11.3

Any additional information you might need to pinpoint the issue just let me know.

Is there a way to create the database schema for the pigallery?

Regards, Marco

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
angelmanstcommented, Sep 10, 2019

Hi Patrick,

I was able to overcome this issue (creating the schema) by dropping the database and recreating it with utf8.

Steps taken: 1 - Signin to MySQL

  • sudo -s
  • mysql

2 - Drop database

  • drop database pigallery;

3 - Recreate database from scratch with utf8

  • CREATE DATABASE pigallery CHARACTER SET utf8;

After this, I login to pigallery online and changed the configuration to use this database. Pigallery created the tables (and I’m guessing, everything it needs).

I had to do several restarts to the application and edit the config.json file with the correct MySQL configuration because it kept defaulting back to SQLite and memory database. But eventually it got the MySQL as primary database and is using it now.

It seams that the issue was trying to reuse a database that was already used by a previous version of pigallery.

Thanks for the tip of recreating the database.

As for the SQLite issue I’ll try to open a new issue with a proper description.

Regards, Marco

0reactions
bpatrikcommented, Sep 12, 2019

Hi,

I’m happy it get solved. There is a mechanism to upgrade to DB scheme if it changes, but that might have some errors.

Best, Patrik

Read more comments on GitHub >

github_iconTop Results From Across the Web

MySQL Error #1071 - max key length is 767 bytes
767 bytes in MySQL version 5.6 (and prior versions), is the stated prefix limitation for InnoDB tables. It's 1,000 bytes long for MyISAM...
Read more >
MariaDB 10.1.38 - Specified key was too long; max key length ...
MariaDB 10.1.38 - Specified key was too long; max key length is 767 bytes ; ALTER TABLE posts ADD UNIQUE ; CREATE ·...
Read more >
[SOLVED] MySQL / MariaDB Specified key was too long
MySQL, MariaDB, Specified, key, was, too, long; max, key, length, is, 767, bytes. MySQL / MariaDB Specified key was too long; max key...
Read more >
MySql /Mariadb error: max key length is 767 byte #4894 - GitHub
I inserted all needed but I received the error "Database setting is not correct: Error 1709: Index column size too large. The maximum...
Read more >
Migrator: MySQL -> MariaDB: max key length is 767 bytes
The reason for this issue is the limitation on the key length in the current SQL version on the target server. In MySQL...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found