我正在尝试部署一个大约10年的项目,使用ruby 1.9.3和rails 2.3.18,最近将数据库升级到Mysql 8.0。在capistrano运行以下命令后发生错误。我用的是Capistrano 2.9.0。executing "cd path/to/project/releases/20230614043133 && bundle exec rake RAILS_ENV=production db:migrate"
以下是完整的日志:
executing "cd path/to/project/releases/20230614043133 && bundle exec rake RAILS_ENV=production db:migrate"
servers: ["X.X.X.X"]
[X.X.X.X] executing command
** [out :: X.X.X.X] path/to/project/shared/bundle/ruby/1.9.1/gems/rake-0.8.7/lib/rake/alt_system.rb:32: Use RbConfig instead of obsolete and deprecated Config.
** [out :: X.X.X.X]
** [out :: X.X.X.X] (in path/to/project/releases/20230614043133)
** [out :: X.X.X.X] ERROR: MySQL database isn't properly encoded!
** [out :: X.X.X.X] Kindly set your character_set_database variable to 'utf8'.
command finished in 5058ms
下面是database.yml设置
development:
adapter: mysql2
encoding: utf8
database: db_development
username: root
password: secret
test:
adapter: mysql2
encoding: utf8
database: db_test
username: root
password:
staging:
adapter: mysql2
encoding: utf8
database: db_staging
socket: /var/run/mysqld/mysqld.sock
username: root
password: secret
production:
adapter: mysql2
encoding: utf8
database: db_production
socket: /var/run/mysqld/mysqld.sock
username: root
password: secret
数据库默认设置为uft8mb3。我尝试将排序规则更改为通用ci,unicode 520,但它们也不起作用。在mysql中运行show variables;
显示character_set_database
变量被设置为utf8mb4
。但是在选择了production_database之后,运行select @@character_set_database
会显示utf8mb3
作为结果。
虽然我不确定我是否走对了路,但任何帮助都将不胜感激。
编辑:我注意到无论我在database.yml中的value
编码中放入什么,错误消息都变成了Kindly set your character_set_database variable to 'value'.
1条答案
按热度按时间14ifxucb1#
通过删除初始化器文件夹中名为MysqlRequirement.rb的文件解决了这个问题,该文件正在检查Mysql版本并引发错误。不是最好的解决方案,但它起作用了。已成功完成数据库迁移。