查询:
CREATE UNIQUE INDEX `index_users_on_email_and_encrypted_password` ON `users` (`email`, `encrypted_password`)
错误:
14:28:47 CREATE UNIQUE INDEX `index_users_on_email_and_encrypted_password` ON `users` (`email`, `encrypted_password`) Error Code: 1071. Specified key was too long; max key length is 767 bytes 0.00048 sec
谁能帮我解决这个问题。我检查了各种解决方案,但没有用。
最佳答案
根据您的加密和列长
您索引中的一个条目可能是
255 x 2 x 4 = 2040
...您应该减小大小(255个字符的密码似乎太长,对于电子邮件也是如此)
例如:
密码(48)
电子邮件(128)
(128 + 48 ) * 4 = 704
如果无法用新的列长度重新创建表
您可以通过这种方式更改列的字符长度
该表必须为空
ALTER TABLE users MODIFY email VARCHAR(128);
ALTER TABLE users MODIFY encrypted_password VARCHAR(48);