About the "MySQL specified key was too long" workaround

Source: Internet
Author: User

1. Description of the problem:

In the execution

CREATE TABLE Goodsandprops (goodsid varchar) NOT NULL, Propsid varchar (+) NOT NULL, Propsvalue varchar (+) NOT NULL, primary key (Goodsid, Propsid, Propsvalue));

When it happens, the three-field key takes up more than 1000 of the limit ((+ +200) * 2 = >), and if it is a two-field key, there is no problem.

2. Solution:

Need to use InnoDB, the new MySQL version is supported InnoDB data engine, do not need special to open. Especially after the 5.5 version, the default is InnoDB. The problem here is that our MySQL version is a bit old, it's a 5.1.47 version,

[[email protected] etc]# mysql--versionmysql Ver 14.14 distrib 5.1.47, for Redhat-linux-gnu (x86_64) using ReadLine 5.1

It is therefore necessary to add Default-storage-engine=innodb to the/etc/my.cnf file under [mysqld] to save.

The modified my.cnf are as follows,

[email protected] etc]# cat my.cnf [mysqld]datadir=/var/lib/mysqlsocket=/var/lib/mysql/mysql.sockuser= mysqldefault-storage-engine=innodb# disabling symbolic-links is recommended to prevent assorted security Riskssymbolic-links=0[mysqld_safe]log-error=/var/log/mysqld.logpid-file=/var/run/mysqld/mysqld.pid

Restart MySQL and no longer describe the problem.


About the "MySQL specified key was too long" workaround

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.