当我执行以下命令时:
ALTER TABLE `mytable` ADD UNIQUE (
`column1` ,
`column2`
);
Run Code Online (Sandbox Code Playgroud)
我收到此错误消息:
#1071 - Specified key was too long; max key length is 767 bytes
Run Code Online (Sandbox Code Playgroud)
有关column1和column2的信息:
column1 varchar(20) utf8_general_ci
column2 varchar(500) utf8_general_ci
Run Code Online (Sandbox Code Playgroud)
我认为varchar(20)只需要21个字节,而varchar(500)只需要501个字节.所以总字节数是522,小于767.那么为什么我会得到错误信息呢?
#1071 - Specified key was too long; max key length is 767 bytes
Run Code Online (Sandbox Code Playgroud) 什么是Unicode的基础以及为什么需要UTF-8或UTF-16?我在Google上研究了这个并在这里搜索过,但我不清楚.
在VSS进行文件比较时,有时会有消息说这两个文件有不同的UTF.为什么会这样呢?
请简单解释一下.
我认识到电子邮件地址基本上可以无限长,所以我在varchar电子邮件地址字段上施加的任何大小都是任意的.但是,我想知道"标准"是什么?你们有多长时间制作它?(姓名字段的相同问题......)
更新:显然,电子邮件地址的最大长度为320(<= 64名称部分,<= 255域).你用这个吗?
我只是在VM上设置了debian 8.3并在本教程之后安装了xampp .一切正常,直到我尝试创建一个新表:
create table testtable
(
id int(10) not null auto_increment,
firstname varchar(255) collate utf8mb4_german2_ci not null,
lastname varchar(255) collate utf8mb4_german2_ci not null,
primary key (id),
unique key (lastname)
)engine = innodb default charset=utf8mb4, collate=utf8mb4_german2_ci
Run Code Online (Sandbox Code Playgroud)
我得到了错误:#1709 - Index column size too large. The maximum column size is 767 bytes.
然后我发现这来自于prefix limitation限制为767Byte Innodb并且我可以通过在my.cnf文件中设置innodb_large_prefix来解决这个问题.但我找不到文件,它不在下,/etc/而且没有 - 文件夹,我发现/etc/mysql/的唯一,但是,在我添加到文件并重新启动lampp之后.我仍然得到同样的错误.我做错了什么?my.cnf/opt/lampp/etc/innodb_large_prefix=1
编辑:SELECT version()返回5.6.14,所以innodb_large_prefix应该支持.
edit2:我知道我可以解决这个问题,只需将键的一部分设置为索引即可获得767Byte.但我想知道如何正确配置mysql.
[Illuminate\Database\QueryException] SQLSTATE [42000]:语法错误或访问冲突:1071指定密钥太长; 最大密钥长度为767字节(SQL:alter tabl e users添加唯一users_email_unique(email))
[PDOException] SQLSTATE [42000]:语法错误或访问冲突:1071指定密钥太长; 最大密钥长度为767字节
怎么了?我正在使用laravel 5.3
我正在尝试在 laravel 中创建一个登录系统。我已经更新了环境。文件包含一个名为 kokodb 的数据库。但是,当我在 cmd 中运行此代码“ php artisan migrate ”时,出现以下错误:
在 Connection.php 第 647 行:
SQLSTATE[HY000] [2054] 服务器向客户端发送了未知的字符集。请向开发人员报告(SQL:select * from information_schema.tables where table_schema = kokodb and table_name = migrations)
在 Connector.php 第 68 行:
SQLSTATE[HY000] [2054] 服务器向客户端发送了未知的字符集。请向开发商举报
在 Connector.php 第 68 行:
PDO::__construct():服务器向客户端发送了未知的字符集 (255)。请向开发商举报
你能帮我么。我在其他地方没有找到解决这个问题的方法。
我在使用 laravel migrate 命令时遇到问题。表明 :
SQLSTATE[42000]:语法错误或访问冲突:1071 指定的键太长;最大密钥长度为 1000 字节(SQL:alter table
usersadd uniqueusers_email_unique(
但是我的 mysql 版本是 5.7.14,我的字符集是:
mysql> show variables like "%char%";
+--------------------------+-------------------------------------------------+
| Variable_name | Value |
+--------------------------+-------------------------------------------------+
| character_set_client | utf8mb4 |
| character_set_connection | utf8mb4 |
| character_set_database | utf8mb4 |
| character_set_filesystem | binary |
| character_set_results | utf8mb4 |
| character_set_server | utf8mb4 |
| character_set_system | utf8 |
| character_sets_dir | D:\wamp64\bin\mysql\mysql5.7.14\share\charsets\ |
+--------------------------+-------------------------------------------------+
Run Code Online (Sandbox Code Playgroud)
所以不应该像医生所说的那样有任何问题。有人可以帮助我吗?
我正在使用laravel 5.6.17和php 7.2; 当我运行php artisan migrate命令时,我收到以下错误.
有关更多信息,已在声明的数据库中创建了默认表"users"和"migrations".
laravel不支持php 7.2吗?
图片:laravel 5.6.17 php artisan migrate错误
Migration table created successfully.
Illuminate\Database\QueryException : SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes (SQL: alter table `users` add unique `users_email_unique`(`email`))
at D:\xampp\htdocs\laravel\vendor\laravel\framework\src\Illuminate\Database\Connection.php:664
660| // If an exception occurs when attempting to run a query, we'll format the error
661| // message to include the bindings with SQL, which will make this exception a …Run Code Online (Sandbox Code Playgroud) 我正在使用 Laravel 并且我有功能迁移:
public function up()
{
Schema::create('products', function (Blueprint $table) {
$table->increments('id');
$table->string('title')->unique();
$table->string('slug')->unique();
$table->string('subtitle');
$table->integer('price');
$table->text('description');
$table->boolean('featured')->default(false);
$table->timestamps();
});
}
Run Code Online (Sandbox Code Playgroud)
当我在我的 cmd 上执行“php artisan migrate”时出现错误
Migration table created successfully.
Migrating: 2014_10_12_000000_create_users_table
Illuminate\Database\QueryException
SQLSTATE[42000]: Syntax error or access violation: 1071 La clé est trop longue. Longueur maximale: 1000 (SQL: alter table `users` add unique `users_username_unique`(`username`))
at C:\Users\linda\lynda-master\vendor\laravel\framework\src\Illuminate\Database\Connection.php:671
667| // If an exception occurs when attempting to run a query, we'll format the error
668| // message to include the …Run Code Online (Sandbox Code Playgroud) laravel ×3
mysql ×3
php ×2
varchar ×2
byte ×1
convention ×1
encoding ×1
innodb ×1
laravel-5.3 ×1
laravel-5.4 ×1
laravel-5.6 ×1
laravel-7 ×1
migrate ×1
php-7 ×1
sql ×1
system ×1
unicode ×1
utf-16 ×1
utf-8 ×1
utf8mb4 ×1
wampserver ×1