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