Hello, First of all I am not a Ruby programmer. The reason I am writing this post is because I took over the administration of a CentOS-server running a Ruby-application because the former administrator is no longer available in the company. I am novice in both Linux and Ruby so bear with me. As stated, we have a CentOS server running Apache and Ruby 1.8.7. We have a Ruby application with a database.yml pointint to two adapters. One mysql for the application itself to store data, and one adapter for reading data. Both of them are pointing towards localhost. Now we need to move the reading database from localhost to remote.host.local since we have a new mysql server in the network. When i change the host: localhost to host: remote.host.local i get 400 Internal server error when i start my application. I have verified the connection from the CentOS server, and to the remote server. Iptables is configured to pass through data on port 3306 The remote MySQL server is accepting data from user@ip-adress-of-CentOS. Privileges is configured to GRANT ALL on the database from the remote user. When i run mysql -h remote.host.local -u user -p i get a valid connection. Is there anywhere else but the database.yml file i need to specify something? I have verified with the developer of the application that he uses only database.yml to connect to the MySQL server. My hair is turning gray because of this problem... Thank you in advance. David. -- Posted via http://www.ruby-forum.com/. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 24 January 2012 10:56, David Ekdahl <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Hello, > > First of all I am not a Ruby programmer. The reason I am writing this > post is because I took over the administration of a CentOS-server > running a Ruby-application because the former administrator is no longer > available in the company. I am novice in both Linux and Ruby so bear > with me. > > As stated, we have a CentOS server running Apache and Ruby 1.8.7. We > have a Ruby application with a database.yml pointint to two adapters. > One mysql for the application itself to store data, and one adapter for > reading data. Both of them are pointing towards localhost. > > Now we need to move the reading database from localhost to > remote.host.local since we have a new mysql server in the network. > > When i change the > host: localhost to host: remote.host.local i get 400 Internal server > error when i start my application. > > I have verified the connection from the CentOS server, and to the remote > server. Iptables is configured to pass through data on port 3306 > The remote MySQL server is accepting data from user@ip-adress-of-CentOS. > Privileges is configured to GRANT ALL on the database from the remote > user. > > When i run mysql -h remote.host.local -u user -p i get a valid > connection. > > Is there anywhere else but the database.yml file i need to specify > something? I have verified with the developer of the application that he > uses only database.yml to connect to the MySQL server.Have a look in the rails log (log/development.log or log/production.log in the rails project folder dependent on which mode you are using) to see if there is more info there. Colin> > My hair is turning gray because of this problem... > Thank you in advance. > David. > > -- > Posted via http://www.ruby-forum.com/. > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en. >-- gplus.to/clanlaw -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Colin Law wrote in post #1042264:> On 24 January 2012 10:56, David Ekdahl <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: >> One mysql for the application itself to store data, and one adapter for >> server. Iptables is configured to pass through data on port 3306 >> The remote MySQL server is accepting data from user@ip-adress-of-CentOS. >> Privileges is configured to GRANT ALL on the database from the remote >> user. >> >> When i run mysql -h remote.host.local -u user -p i get a valid >> connection. >> >> Is there anywhere else but the database.yml file i need to specify >> something? I have verified with the developer of the application that he >> uses only database.yml to connect to the MySQL server. > > Have a look in the rails log (log/development.log or > log/production.log in the rails project folder dependent on which mode > you are using) to see if there is more info there. > > Colin > >> To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. >> > > > > -- > gplus.to/clanlawHello and thank you for the fast answer. I am not in my office at the moment so I cannot see the files you posted. Just to verify (because i am novice) are those files located in the application itself or inside the Ruby installation folder? Is there a way inside the application to se where logs are to be written? David -- Posted via http://www.ruby-forum.com/. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 24 January 2012 11:10, David Ekdahl <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Colin Law wrote in post #1042264: >> On 24 January 2012 10:56, David Ekdahl <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: >>> One mysql for the application itself to store data, and one adapter for >>> server. Iptables is configured to pass through data on port 3306 >>> The remote MySQL server is accepting data from user@ip-adress-of-CentOS. >>> Privileges is configured to GRANT ALL on the database from the remote >>> user. >>> >>> When i run mysql -h remote.host.local -u user -p i get a valid >>> connection. >>> >>> Is there anywhere else but the database.yml file i need to specify >>> something? I have verified with the developer of the application that he >>> uses only database.yml to connect to the MySQL server. >> >> Have a look in the rails log (log/development.log or >> log/production.log in the rails project folder dependent on which mode >> you are using) to see if there is more info there. >> >> Colin >> >>> To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>> To unsubscribe from this group, send email to >> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>> For more options, visit this group at >> http://groups.google.com/group/rubyonrails-talk?hl=en. >>> >> >> >> >> -- >> gplus.to/clanlaw > > Hello and thank you for the fast answer. > > I am not in my office at the moment so I cannot see the files you > posted. > > Just to verify (because i am novice) are those files located in the > application itself or inside the Ruby installation folder? Is there a > way inside the application to se where logs are to be written?They are in the log folder within the rails application (so that is a folder log at the same level as the config folder that has database.yml in it). 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Colin Law wrote in post #1042268:> On 24 January 2012 11:10, David Ekdahl <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: >>>> >>>> To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> >> Hello and thank you for the fast answer. >> >> I am not in my office at the moment so I cannot see the files you >> posted. >> >> Just to verify (because i am novice) are those files located in the >> application itself or inside the Ruby installation folder? Is there a >> way inside the application to se where logs are to be written? > > They are in the log folder within the rails application (so that is a > folder log at the same level as the config folder that has > database.yml in it). > > ColinThank you. I will take a look when I''m back at my office. David -- Posted via http://www.ruby-forum.com/. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Hello, The log says: Mysql::Error - Can''t connect to MySQL server on ''remote.host.local'' (13): But why... When I run mysql -h remote.host.local -u user -p form the server it works. -- Posted via http://www.ruby-forum.com/. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Tue, Jan 24, 2012 at 5:40 PM, David Ekdahl <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Hello, > > The log says: > Mysql::Error - Can''t connect to MySQL server on ''remote.host.local'' > (13): > > But why... When I run mysql -h remote.host.local -u user -p form the > server it works. >Could you run this on your database.yml file (from your Rails root) and check if it looks like you expect? Subtle space/tab errors may yield an invalid database.yml file. $ irb 1.9.3p0 :001 > require ''yaml''; YAML::load(File.open(''config/database.yml'')) => {"development"=>{"adapter"=>"postgresql", "encoding"=>"unicode", "pool"=>5, "username"=>"peterv", "password"=>nil, "min_messages"=>"log", "database"=>"billing_engine_development"}, ...} HTH, Peter -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Peter Vandenabeele wrote in post #1042328:> On Tue, Jan 24, 2012 at 5:40 PM, David Ekdahl <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> > wrote: > >> Hello, >> >> The log says: >> Mysql::Error - Can''t connect to MySQL server on ''remote.host.local'' >> (13): >> >> But why... When I run mysql -h remote.host.local -u user -p form the >> server it works. >> > > Could you run this on your database.yml file (from your Rails root) > and check if it looks like you expect? Subtle space/tab errors may > yield an invalid database.yml file. > > $ irb > 1.9.3p0 :001 > require ''yaml''; > YAML::load(File.open(''config/database.yml'')) > => {"development"=>{"adapter"=>"postgresql", "encoding"=>"unicode", > "pool"=>5, "username"=>"peterv", "password"=>nil, "min_messages"=>"log", > "database"=>"billing_engine_development"}, ...} > > HTH, > > PeterHello Peter, thank''s for your answer. Do you want me to just copy and paste the code inside my database.yml file? What does it do? David -- Posted via http://www.ruby-forum.com/. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Tue, Jan 24, 2012 at 6:07 PM, David Ekdahl <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Peter Vandenabeele wrote in post #1042328: > > On Tue, Jan 24, 2012 at 5:40 PM, David Ekdahl <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> > > wrote: > > > >> Hello, > >> > >> The log says: > >> Mysql::Error - Can''t connect to MySQL server on ''remote.host.local'' > >> (13): > >> > >> But why... When I run mysql -h remote.host.local -u user -p form the > >> server it works. > >> > > > > Could you run this on your database.yml file (from your Rails root) > > and check if it looks like you expect? Subtle space/tab errors may > > yield an invalid database.yml file. > > > > $ irb > > 1.9.3p0 :001 > require ''yaml''; > > YAML::load(File.open(''config/database.yml'')) > > => {"development"=>{"adapter"=>"postgresql", "encoding"=>"unicode", > > "pool"=>5, "username"=>"peterv", "password"=>nil, "min_messages"=>"log", > > > > HTH, > > > > Peter > > Hello Peter, thank''s for your answer. > > Do you want me to just copy and paste the code inside my database.yml > file? > > What does it do? >$ irb 1.9.3p0 :001 > require ''yaml''; YAML::load(File.open(''config/database.yml'')) And check the output yourself (no need to copy, may contain passwords etc.). 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. Peter -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 24 January 2012 17:19, Peter Vandenabeele <peter-jNuWw7i2w7syMbTcgqFhxg@public.gmane.org> wrote:> On Tue, Jan 24, 2012 at 6:07 PM, David Ekdahl <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: >> >> Peter Vandenabeele wrote in post #1042328: >> > On Tue, Jan 24, 2012 at 5:40 PM, David Ekdahl <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> >> > wrote: >> > >> >> Hello, >> >> >> >> The log says: >> >> Mysql::Error - Can''t connect to MySQL server on ''remote.host.local'' >> >> (13): >> >> >> >> But why... When I run mysql -h remote.host.local -u user -p form the >> >> server it works. >> >> >> > >> > Could you run this on your database.yml file (from your Rails root) >> > and check if it looks like you expect? Subtle space/tab errors may >> > yield an invalid database.yml file. >> > >> > $ irb >> > 1.9.3p0 :001 > require ''yaml''; >> > YAML::load(File.open(''config/database.yml'')) >> > => {"development"=>{"adapter"=>"postgresql", "encoding"=>"unicode", >> > "pool"=>5, "username"=>"peterv", "password"=>nil, "min_messages"=>"log", >> > >> > HTH, >> > >> > Peter >> >> Hello Peter, thank''s for your answer. >> >> Do you want me to just copy and paste the code inside my database.yml >> file? >> >> What does it do? > > > $ irb > 1.9.3p0 :001 > require ''yaml''; YAML::load(File.open(''config/database.yml'')) > > And check the output yourself (no need to copy, may contain passwords etc.). > > 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 -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Peter Vandenabeele wrote in post #1042334:> On Tue, Jan 24, 2012 at 6:07 PM, David Ekdahl <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> > wrote: > >> >> But why... When I run mysql -h remote.host.local -u user -p form the >> > => {"development"=>{"adapter"=>"postgresql", "encoding"=>"unicode", >> >> What does it do? >> > > $ irb > 1.9.3p0 :001 > require ''yaml''; > YAML::load(File.open(''config/database.yml'')) > > And check the output yourself (no need to copy, may contain passwords > etc.). > > 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. > > PeterI''m unsure what to do with this. As stated I am not a ruby programmer. I have never worked with Ruby ever. Could you please give me a little more information on what to do, or at least point me in a direction and I will try to figure it out myself. Should I or should I not type this in my database.yml file? David. -- Posted via http://www.ruby-forum.com/. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Colin Law wrote in post #1042340:> On 24 January 2012 17:19, Peter Vandenabeele <peter-jNuWw7i2w7syMbTcgqFhxg@public.gmane.org> > 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 > > ColinThank 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"}} -- Posted via http://www.ruby-forum.com/. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Peter Vandenabeele
2012-Jan-24 21:18 UTC
Re: Re: Re: Re: Remote MySQL database.yml problem
On Tue, Jan 24, 2012 at 6:52 PM, David Ekdahl <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Colin Law wrote in post #1042340: > > On 24 January 2012 17:19, Peter Vandenabeele <peter-jNuWw7i2w7syMbTcgqFhxg@public.gmane.org> > > 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 HTH, Peter -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 24 January 2012 21:18, Peter Vandenabeele <peter-jNuWw7i2w7syMbTcgqFhxg@public.gmane.org> wrote:> On Tue, Jan 24, 2012 at 6:52 PM, David Ekdahl <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: >> >> Colin Law wrote in post #1042340: >> > On 24 January 2012 17:19, Peter Vandenabeele <peter-jNuWw7i2w7syMbTcgqFhxg@public.gmane.org> >> > 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 consoleDavid: 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Peter Vandenabeele
2012-Jan-24 21:35 UTC
Re: Re: Re: Re: Remote MySQL database.yml problem
On Tue, Jan 24, 2012 at 10:32 PM, Colin Law <clanlaw-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> On 24 January 2012 21:18, Peter Vandenabeele <peter-jNuWw7i2w7syMbTcgqFhxg@public.gmane.org> > wrote: >...> > Warning, it that command succeeds, you may be connected directly to your > > production database, be careful. >...> > 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. >Thanks for that correction. I should have stated that advise too, before any other ... Peter -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.