I am trying get my first simple project in rails to run. I have installed wamp. And trying to make use of that same mysql db server installed with wamp. But I decided to make use of webrick, and not apache. Hoping that the configuration would be easier. I edited the database.yml file and the gemfile under my projects directory:
# MySQL. Versions 4.1 and 5.0 are recommended.
#
# Install the MySQL driver:
# gem install mysql2
#
# And be sure to use new-style password hashing:
# http://dev.mysql.com/doc/refman/5.0/en/old-client.html
development:
adapter: mysql
encoding: utf8
reconnect: false
database: rubybeg_test
pool: 5
username: root
password: 1234
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
encoding: utf8
reconnect: false
database: rubybeg_test
pool: 5
username: root
password: 1234
host: localhost
开发者_如何学JAVA
production:
adapter: mysql
encoding: utf8
reconnect: false
database: rubybeg_test
pool: 5
username: root
password: 1234
host: localhost
And here's gemfile:
source 'http://rubygems.org'
gem 'rails', '3.0.5'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'mysql'
# Use unicorn as the web server
# gem 'unicorn'
# Deploy with Capistrano
# gem 'capistrano'
# To use debugger (ruby-debug for Ruby 1.8.7+, ruby-debug19 for Ruby 1.9.2+)
# gem 'ruby-debug'
# gem 'ruby-debug19', :require => 'ruby-debug'
# Bundle the extra gems:
# gem 'bj'
# gem 'nokogiri'
# gem 'sqlite3-ruby', :require => 'sqlite3'
# gem 'aws-s3', :require => 'aws/s3'
# Bundle gems for the local environment. Make sure to
# put test-only gems in this group so their generators
# and rake tasks are available in development mode:
# group :development, :test do
# gem 'webrat'
# end
I used the command gem install mysql because mysql2 doesn't work for me.
What I did was to launch wampserver and stopped the apache service. It would take forever to load: http://localhost:3000/rails/info/properties Then webrick would crash. But if I do not launch wamp, I get this:
Did you configure mysql to run on a port other than 3306? If you're using a different port than that, you'll need to edit as follows:
development:
adapter: mysql
encoding: utf8
reconnect: false
database: rubybeg_test
pool: 5
username: root
password: 1234
host: localhost
port: 3306 #replace with the correct port
If that doesn't work, also try changing localhost to 127.0.0.1 in order to force it to use TCP. Sometimes it tries to use sockets and cannot find the socket file.
精彩评论