Dino Geek, try to help you

How to resolve Error 1071: Specified key was too long; max key length is 767 bytes in MariaDB?


You may encounter Error 1071 in MariaDB when trying to create an index on a column or a set of columns larger than 767 bytes, which is the default maximum key length in InnoDB. Follow these steps to resolve the error:

1. `ALTER DATABASE database_name CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci;`

Replace `database_name` with your actual database name.

1. For each table, execute the following statements:

- `ALTER TABLE table_name CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;`
- `ALTER TABLE table_name ROW_FORMAT=DYNAMIC;`

Replace `table_name` with your actual table name.

1. In your MariaDB/MySQL configuration file (usually `my.cnf` or `my.ini`), add the following lines under the [mysqld] section:

```
innodb_large_prefix=on
innodb_file_format=barracuda
innodb_file_per_table=true
```
1. Restart the MariaDB/MySQL service.

This setting allows you to store up to 3072 bytes into an InnoDB index, which should be enough for any key.

Remember to make a backup of your database before making these changes.

If you are still encountering issues, you may also consider reducing the size of your column or setting a prefix length on your index.


Simply generate articles to optimize your SEO
Simply generate articles to optimize your SEO





DinoGeek offers simple articles on complex technologies

Would you like to be quoted in this article? It's very simple, contact us at dino@eiki.fr

CSS | NodeJS | DNS | DMARC | MAPI | NNTP | htaccess | PHP | HTTPS | Drupal | WEB3 | LLM | Wordpress | TLD | Domain name | IMAP | TCP | NFT | MariaDB | FTP | Zigbee | NMAP | SNMP | SEO | E-Mail | LXC | HTTP | MangoDB | SFTP | RAG | SSH | HTML | ChatGPT API | OSPF | JavaScript | Docker | OpenVZ | ChatGPT | VPS | ZIMBRA | SPF | UDP | Joomla | IPV6 | BGP | Django | Reactjs | DKIM | VMWare | RSYNC | Python | TFTP | Webdav | FAAS | Apache | IPV4 | LDAP | POP3 | SMTP

| Whispers of love (API) | Déclaration d'Amour |






Legal Notice / General Conditions of Use