运行rails时的“no such file to load -- sqlite3”错误

运行rails时的“no such file to load -- sqlite3”错误

我在运行php?name=rails" onclick="tagshow(event)" class="t_tag">rails项目的时候报错:
no such file to load -- sqlite3

好像是因为rails默认数据库是sqlite3的原因
我把数据库配置改成了mysql
配置文件如下:

development:
 adapter: mysql
 database: r4rmusic1_development
 timeout: 5000
 username:root
 password:123
 host:127.0.0.1

test:
 adapter: mysql
 database: r4rmusic1_test
 timeout: 5000
 username:root
 password:123
 host:127.0.0.1

production:
 adapter: mysql
 database: r4rmusic1_production
 timeout: 5000
 username:root
 password:123
 host:127.0.0.1

可是还是不行
控制台信息如下:
=> Booting WEBrick...
c:/ruby/lib/ruby/1.8/yaml.rb:133:in `load': syntax error on line 5, col 2: ` password:123' (ArgumentError)
   from c:/ruby/lib/ruby/1.8/yaml.rb:133:in `load'
   from c:/ruby/lib/ruby/gems/1.8/gems/rails-2.1.1/lib/initializer.rb:716:in `database_configuration'
   from c:/ruby/lib/ruby/gems/1.8/gems/rails-2.1.1/lib/initializer.rb:340:in `initialize_database'
   from c:/ruby/lib/ruby/gems/1.8/gems/rails-2.1.1/lib/initializer.rb:124:in `process'
   from c:/ruby/lib/ruby/gems/1.8/gems/rails-2.1.1/lib/initializer.rb:97:in`send'
   from c:/ruby/lib/ruby/gems/1.8/gems/rails-2.1.1/lib/initializer.rb:97:in`run'
   from D:/MyWorkspace/test/config/environment.rb:13
   from c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require'
   ... 10 levels...
   from c:/ruby/lib/ruby/gems/1.8/gems/rails-2.1.1/lib/commands/server.rb:39
   from c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require'
   from c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require'
   from script/server:3

密码配的不对?
应该怎么写?
rails必须要配置数据库是吗
我把database.yml清空了之后会报错
请高手指教~~
多谢
Rails2.0以前,Rails是把MySQL数据库作为默认的数据库配置的,也就是你不用配置MySQL的数据库就可以直接使用了。但由于去年底,MySQL已经属于Sun公司了(虽然它还是免费的),Rails2.0以后就把sqlite3作为默认的数据库来使用了。

因此,现在在Rails中使用MySQL是要做一点配置的,但就一点,也就是链接。只要你把数据库连接上(各种数据库的驱动),Rails就可以帮你生成配置文件的。也就是你提到的database.yml文件。这个文件不可以是空的。

你的问题就在密码上了(你的错误信息说:密码参数有错)。如果你在建立数据库时没有建立密码,就在密码那项保留空;如果你建立了密码,就把你的密码直接写在密码那项里。

另外,我看到你的例子,可能是Ruby For Rails那本书里的吧。那本书已经比较老了,建议你去看基于Rails2.0写的书,这样学习起来会没有因Rails升级引起的问题。

请参考这个,看看是否对你有帮助。
http://www.ruby-lang.org.cn/forums/thread-6681-1-1.html

http://www.ruby-lang.org.cn/forums/thread-6698-1-1.html

谢谢!
谢谢 就是那本书 没想到到2.0变化这么大
那我怎么和mysql建立连接
需要导入jar包吗?
我的密码设的没有问题
就是通不过
是需要配置一个socket吗
我看网上有一个例子是这么写的:
socket: /opt/local/var/run/mysql5/mysqld.sock
我不明白什么意思
通过它就可以和mysql连接吗
不用导入什么库什么的?
哪位可以给我指点一下
解决了
配置如下:
development:
 adapter: mysql
 encoding: utf8 
 database: r4rmusic1_development
 username: root
 password: mysql
 host: localhost
 socket: /opt/local/var/run/mysql5/mysqld.sock

test:
 adapter: mysql
 encoding: utf8 
 database: r4rmusic1_test
 username: root
 password: mysql
 host: localhost
 socket: /opt/local/var/run/mysql5/mysqld.sock

production:
 adapter: mysql
 encoding: utf8 
 database: r4rmusic1_production
 username: root
 password: mysql
 host: localhost
 socket: /opt/local/var/run/mysql5/mysqld.sock

就是加入socket就行
另外比较诡异的一点是
password:mysql
password: mysql
上面两种配置的结果是不一样的
冒号后面不加空格的话就会出错
就说我密码参数错误
汗了
-3-
飞猪,.我爱你`....太强大了`.
..我一直用老版本的书`.结果很多东西都是运行不了`...给我这个新手带来了很大的困惑........


谢谢了~~`
也帮我看看
# SQLite version 3.x
# gem install sqlite3-ruby (not necessary on OS X Leopard)
development:
 adapter: mysql
 database: chensite_development
 encoding:utf8
 username: root
 password: 
 pool: 5
 timeout: 5000
 host:localhost

# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
 adapter: mysql
 database: chensite_test
 encoding:utf8
 username: root
 password:
 host:127.0.0.1
 pool: 5
 timeout: 5000

production:
 adapter: mysql
 database: chensite_production
 encoding:utf8
 username: root
 password:
 host:127.0.0.1
 pool: 5
 timeout: 5000


报的错是:
=> Booting WEBrick...
/usr/local/lib/ruby/1.8/yaml.rb:133:in `load': syntax error on line 6, col 2: ` username:root' (ArgumentError)
    from /usr/local/lib/ruby/1.8/yaml.rb:133:in `load'
    from /usr/local/lib/ruby/gems/1.8/gems/rails-2.2.2/lib/initializer.rb:819:in `database_configuration'
    from /usr/local/lib/ruby/gems/1.8/gems/rails-2.2.2/lib/initializer.rb:391:in `initialize_database'
    from /usr/local/lib/ruby/gems/1.8/gems/rails-2.2.2/lib/initializer.rb:139:in `process'
    from /usr/local/lib/ruby/gems/1.8/gems/rails-2.2.2/lib/initializer.rb:112:in `send'
    from /usr/local/lib/ruby/gems/1.8/gems/rails-2.2.2/lib/initializer.rb:112:in `run'
    from /home/hk/rubyspace/chensite/config/environment.rb:13
    from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
    from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
    from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:153:in `require'
    from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:521:in `new_constants_in'
    from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:153:in `require'
    from /usr/local/lib/ruby/gems/1.8/gems/rails-2.2.2/lib/commands/servers/webrick.rb:59
    from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
    from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
    from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:153:in `require'
    from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:521:in `new_constants_in'
    from /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:153:in `require'
    from /usr/local/lib/ruby/gems/1.8/gems/rails-2.2.2/lib/commands/server.rb:49
    from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
    from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
    from ./script/server:3
    from -e:4:in `load'
    from -e:4

这个怎么解决阿。
我是新手。
看了,感觉不错,谢谢您提供


一同事甲在电脑前检查图纸,另一同事乙坐在他后面跟他闹着玩,不时戳戳他的背,摸摸他的头,甲说:“求求你不要再弄了,再弄我要叫了。”

  同事乙说:“你叫啊,你叫破喉咙也没人听见。”

  (周星驰《九品芝麻官》里的台词)


-------------------------
a Cheap WoW Gold site: wow gold, wow gold, wow gold, FFXI Gil, final fantasy gil, World Of Warcraft gold