On 24 January 2012 21:18, Peter Vandenabeele <pe...@vandenabeele.com> wrote:
> On Tue, Jan 24, 2012 at 6:52 PM, David Ekdahl <li...@ruby-forum.com> wrote:
>>
>> Colin Law wrote in post #1042340:
>> > On 24 January 2012 17:19, Peter Vandenabeele <pe...@vandenabeele.com>
>> > wrote:
>> >>> >> (13):
>> >>> > 1.9.3p0 :001 > require 'yaml';
>> >>> Do you want me to just copy and paste the code inside my database.yml
>> >> It parses the database.yml file (which is obviously a YAML file). If
>> >> you
>> >> have
>> >> formatting problems in that file, it may be visible in the result.
>> >
>> > In case it is still not clear, Peter means you to open a terminal and
>> > cd to the top level of your rails projectexit.  Then type
>> > irb
>> > and when it comes back with the prompt enter the require .... line and
>> > see what it says.  You can then check the host, database, username and
>> > pwd are correct for the environment (development or production).
>> > To get back to the terminal prompt type exit
>> >
>> > Colin
>>
>> Thank you.
>>
>> This is my result. Does it look suspicious? I edited out some sensitive
>> information...
>>
>> irb(main):002:0* YAML::load(File.open('database.yml'))
>> => {"projectname"=>{"username"=>"user", "adapter"=>"mysql",
>> "database"=>"somedatabase", "host"=>"localhost",
>> "password"=>"some_password"}, "projectname02"=>{"encoding"=>"utf8",
>> "username"=>"user", "adapter"=>"mysql", "database"=>"somedatabase",
>> "host"=>"remote.host.local", "password"=>"somepassword"}}
>
>
>
> If I understand correctly, this means that the 2 "environments" for this
> system
> are 'projectname' and 'projectname02'.
>
> You may try this to confirm that assumption:
>
> $ RAILS_ENV=projectname rails console
>
> (Note: take over the spaces _exactly_ as I show above; no spaces around the
> '=')
>
> If that does something useful, than we confirmed that scenario.
>
> Warning, it that command succeeds, you may be connected directly to your
> production database, be careful.
>
> If you wanted to connect to a development database in default
> 'development' mode, you would need a stanza in you config/database.yml
> of the form:
>
> development:
>   adapter: mysql2
>   host: localhost
>   username: user...
>   password: pass...
>   pool: 5
>   timeout: 5000
>   socket: /var/run/mysqld/mysqld.sock
>   database: dbname
>
> ^
> ||
> These are all exactly 2 spaces (not tabs or anything else)
>
> With that 'development' stanza in place, you could try:
>
> $ rake db:create # assuming the development database does not exist yet
> $ rake db:migrate
> $ rails console

David:  Before doing any more, have you checked that you have an up to
date backup of the database (if it is important)?  If not then don't
think about doing anything until you have a backup and have checked
that you can restore it.

Secondly I notice in your database.yml you have mysql as the adapter
rather than mysql2 which is what is used now.  Does anyone know
whether that might be an issue?

Colin

Colin

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to