如何把redmine的数据从sqlite导入到mysql
一段时间以来,一直使用redmine+sqlite3来管理项目,但是发现随着管理数据的膨胀,redmine速度越来越慢,怀疑和sqlite的性能有关, 想把数据库换成mysql, 所以就必须把数据从sqlite3导入到mysql。实现原理
利用rails的plugin yaml_db
把数据从sqlite导入到yaml格式的文件里,然后再把数据从文件中导入到mysql里。
具体步骤
1. 安装yaml_db插件。
// $REDMINE_ROOT 为redmine安装目录
cd $REDMINE_ROOT
ruby script/plugin install git://github.com/adamwiggins/yaml_db.git
2. 把redmine的管理数据从sqlite中导到yaml文件中, 默认dump文件是redmine目录下db/data.yml。
rake db:dump RAILS_ENV=production
3. 把redmine数据库相关配置改成mysql。
[*]安装mysql相关包。
gem install mysql
[*]如果使用mysql5.1以上的版本,上述命令很有可能会出错。需要下载libmySQL.dll
, 并放置到ruby的bin目录下。
[*]在redmine安装目录下,修改文件config/database.yml中production部分。
production:
adapter: mysql
database: redmine
host: localhost
username: redmine
password: my_password
[*]如果mysql不是用的标准端口3306, 那么需要在上述配置中加入以下一行。
port: 3307
[*]在mysql中生成所需要的table和用户。
create database redmine character set utf8;
create user 'redmine'@'localhost' identified by 'my_password';
grant all privileges on redmine.* to 'redmine'@'localhost';
4. 把数据从2.生成的文件db/data.yaml导入到mysql中。
rake db:load RAILS_ENV=production
5. 重新启动redmine, 此时后台DB应该就是mysql了, 速度应该比sqlite提高许多。
页:
[1]