MySQL 5.5 / Redmine 3.4.3 / Ruby23-x64 --- Mysql2::Error: Specified key was too long; max key length is 767 bytes
Added by Leslie Martinez almost 7 years ago
Hi,
Description :¶
I am unable to run : bundle exec rake db:migrate
Error :¶
== 91 ChangeChangesetsRevisionToString: migrating ============================= -- index_exists?(:changesets, [:repository_id, :revision], {:name=>:changesets_repos_rev}) -> 0.0005s -- index_exists?(:changesets, [:repository_id, :revision], {:name=>:altered_changesets_repos_rev}) -> 0.0003s -- change_column(:changesets, :revision, :string, {:null=>false}) -> 0.0129s -- add_index(:changesets, [:repository_id, :revision], {:unique=>true, :name=>:changesets_repos_rev}) rake aborted! StandardError: An error has occurred, all later migrations canceled: Mysql2::Error: Specified key was too long; max key length is 767 bytes: CREATE UNIQUE INDEX `changesets_repos_rev` ON `changesets` (`repository_id`, `revision`) C:/Users/lmartine/Documents/leslie/redmine-3.4.3/db/migrate/091_change_changesets_revision_to_string.rb:17:in `up' C:in `migrate' Caused by: ActiveRecord::StatementInvalid: Mysql2::Error: Specified key was too long; max key length is 767 bytes: CREATE UNIQUE INDEX `changesets_repos_rev` ON `changesets` (`repository_id`, `revision`) C:/Users/lmartine/Documents/leslie/redmine-3.4.3/db/migrate/091_change_changesets_revision_to_string.rb:17:in `up' C:in `migrate' Caused by: Mysql2::Error: Specified key was too long; max key length is 767 bytes C:/Users/lmartine/Documents/leslie/redmine-3.4.3/db/migrate/091_change_changesets_revision_to_string.rb:17:in `up' C:in `migrate' Tasks: TOP => db:migrate (See full trace by running task with --trace)
Environment :¶
- MySQL 5.5
- Redmine 3.4.3
- Ruby23-x64
Previous Actions :¶
- Download Redmine V3.4 (https://www.redmine.org/projects/redmine/wiki/RedmineInstall#fn1)
- Extract : C:\Users\lmartine\Documents\leslie\redmine-3.4.3
- Download and install Ruby V2.3 (C:\Ruby23-x64)
- Download Ruby DevKit (https://github.com/oneclick/rubyinstaller/wiki/Development-Kit)
- Extract : C:\Ruby23-x64\DevKit
- cd C:\Ruby23-x64\DevKit
- ruby dk.rb init
- ruby dk.rb install
- gem install redcarpet v '3.4.0' Install ImageMagick-6.9.8-2-Q8-x64-dll(http://www.ownway.info/Ruby/rmagick/howtoinstall/windows/en)
- set CPATH=C:\ImageMagick-6.9.8-Q8\include
- set LIBRARY_PATH=C:\ImageMagick-6.9.8-Q8\lib
- cd C:\Users\lmartine\Documents\leslie\redmine-3.4.3
- gem install rmagick
- gem install bundler
- bundle install --without development test
Could you please help me solve this issue ?
Thanks
Leslie
Replies (2)
[SOLVED] MySQL 5.5 / Redmine 3.4.3 / Ruby23-x64 --- Mysql2::Error: Specified key was too long; max key length is 767 bytes - Added by Leslie Martinez almost 7 years ago
Hi,
I found the solution .
It seems to be a problem with the DB creation .
Here is what I did :
COMMAND LINES :¶
mysql -u root -p
drop database redmine
exit
mysql -u root -p -e "CREATE DATABASE redmine DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;"
Thanks
Leslie
RE: MySQL 5.5 / Redmine 3.4.3 / Ruby23-x64 --- Mysql2::Error: Specified key was too long; max key length is 767 bytes - Added by David Gessel about 6 years ago
Still debugging this, still a problem with MySQL 5.6.41. 5.7.7 might fix it. If using the full UTF8 character sets, it is necessary to use utf8mb4 rather than 'utf8' as MySQL's UTF8 implementation isn't quite, so for example:
CREATE DATABASE redmine CHARACTER SET utf8mb4 COLLATE = utf8mb4_unicode_ci;
A good description of why is here: [[https://mathiasbynens.be/notes/mysql-utf8mb4]]
#23586 at the end has a solution to limiting the title length to VARCHAR which would be needed with the above specification for reasons described at mathiasbynens blog where Luc Lalonde advises (sauce is probably nanaya's comment at [[https://github.com/rails/rails/issues/9855#issuecomment-35618750]] ):
Add this script redmine/config/initializers/mysqlpls.rb:
require 'active_record/connection_adapters/abstract_mysql_adapter' module ActiveRecord module ConnectionAdapters class AbstractMysqlAdapter NATIVE_DATABASE_TYPES[:string] = { :name => "varchar", :limit => 191 } end end end