db:migrate ... LoadError:无法加载此类文件

时间:2016-07-22 21:47:40

标签: ruby redmine

我试图将mysmine上的redmine 1.1.3安装迁移到另一台服务器上的ubuntu 16.04上的redmine 3.3.0。

redmine 3.3.0使用apt安装。我能够登录,安装看起来还不错。

我使用mysqldump迁移了数据库,然后尝试运行它,但是我收到了错误:

sudo bundle exec rake db:migrate RAILS_ENV=production --trace
bundler: failed to load command: rake (/usr/local/bin/rake)
LoadError: cannot load such file -- /usr/share/rubygems-integration/all/specifications/bin/rake
/usr/local/bin/rake:23:in `load'
/usr/local/bin/rake:23:in `<top (required)>'

有人可以帮忙吗?

1 个答案:

答案 0 :(得分:0)

回答我自己的问题: 以下命令不是原始命令,而是起作用:

sudo bundle exec /usr/bin/rake db:migrate RAILS_ENV=production

这导致以下错误:

rake aborted!
Gem::LoadError: Specified 'mysql2' for database adapter, but the gem is not loaded. Add `gem 'mysql2'` to your Gemfile (and ensure its version is at the minimum required by ActiveRecord).

要解决此问题:

sudo apt-get install mysql-client libmysqlclient-dev ruby-dev libgmp-dev  build-essential bison openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libxml2-dev autoconf libc6-dev ncurses-dev automake libtool
sudo gem install mysql2

我还更新了/ usr / share / redmine / GemFile并在初始gem声明下添加了这一行:

gem "mysql2"

此外,当您安装redmine时,它为您提供了配置数据库的选项。选择“否”。如果选择“是”,则需要删除在安装过程中创建的redmine数据库并手动创建数据库。以下行假定您创建了旧数据库的备份,并且dumpfile名为/ home / ubuntu / redmine

mysql -u root -p
mysql> create database redmine2 DEFAULT CHARACTER SET utf8;
grant all on redmine2.* TO 'redmine'@'%' IDENTIFIED BY 'password';
mysql> connect redmine2
mysql> source /home/ubuntu/redmine

在此之后,您需要修改/etc/redmine/default/database.yml以更新数据库/用户名/密码的名称

毕竟,在尝试访问redmine URL时,我开始遇到乘客错误。我不得不撤消/ usr / share / redmine / GemFile中的更改。还有一些文件权限问题。希望这有助于某人。