I know that you have to change the database.yml but I don't know what to change it to and how to download MYSQL and all of that jazz.
我知道你必须更改database.yml,但我不知道要改变它以及如何下载MYSQL和所有爵士乐。
2 个解决方案
#1
26
Gemfile:
的Gemfile:
gem 'mysql2'
config/database.yml
配置/ database.yml的
development:
adapter: mysql2
encoding: utf8
reconnect: false
database: db_name_here
pool: 5
username: root
password:
host: localhost
Command line:
命令行:
bundle install
rake db:create
rake db:migrate
Of course MySQL needs to be installed.
当然MySQL需要安装。
If you're creating a new project:
如果您要创建一个新项目:
rails new app_name_here -d mysql
#2
2
I ran into the same problem when trying to use the mysql2 gem with Rails 3.0.9. When I ran rake db:create
after installing the mysql2 gem, it gave me these warnings:
我试图在Rails 3.0.9中使用mysql2 gem时遇到了同样的问题。当我在安装mysql2 gem之后运行rake db:create时,它给了我这些警告:
WARNING: This version of mysql2 (0.3.6) doesn't ship with the ActiveRecord adapter bundled anymore as it's now part of Rails 3.1
警告:此版本的mysql2(0.3.6)不再附带捆绑的ActiveRecord适配器,因为它现在是Rails 3.1的一部分
WARNING: Please use the 0.2.x releases if you plan on using it in Rails <= 3.0.x
警告:如果您打算在Rails <= 3.0.x中使用它,请使用0.2.x版本
To specify that you only want to use the 0.2.x versions of mysql2, edit your Gemfile so that
要指定您只想使用0.2.x版本的mysql2,请编辑您的Gemfile
gem 'mysql2'
becomes
变
gem 'mysql2', '~> 0.2.1'
#1
26
Gemfile:
的Gemfile:
gem 'mysql2'
config/database.yml
配置/ database.yml的
development:
adapter: mysql2
encoding: utf8
reconnect: false
database: db_name_here
pool: 5
username: root
password:
host: localhost
Command line:
命令行:
bundle install
rake db:create
rake db:migrate
Of course MySQL needs to be installed.
当然MySQL需要安装。
If you're creating a new project:
如果您要创建一个新项目:
rails new app_name_here -d mysql
#2
2
I ran into the same problem when trying to use the mysql2 gem with Rails 3.0.9. When I ran rake db:create
after installing the mysql2 gem, it gave me these warnings:
我试图在Rails 3.0.9中使用mysql2 gem时遇到了同样的问题。当我在安装mysql2 gem之后运行rake db:create时,它给了我这些警告:
WARNING: This version of mysql2 (0.3.6) doesn't ship with the ActiveRecord adapter bundled anymore as it's now part of Rails 3.1
警告:此版本的mysql2(0.3.6)不再附带捆绑的ActiveRecord适配器,因为它现在是Rails 3.1的一部分
WARNING: Please use the 0.2.x releases if you plan on using it in Rails <= 3.0.x
警告:如果您打算在Rails <= 3.0.x中使用它,请使用0.2.x版本
To specify that you only want to use the 0.2.x versions of mysql2, edit your Gemfile so that
要指定您只想使用0.2.x版本的mysql2,请编辑您的Gemfile
gem 'mysql2'
becomes
变
gem 'mysql2', '~> 0.2.1'