hi everyone I''ve got two machines here: a Powerbook and a Linux box running MySQL. The MySQL user privileges seem to be configured properly, e.g. I can connect to a database using "mysql" from the Powerbook, alter the tables etc without any problems. However, I can''t get Rails to connect to the same database. (just a simple app with one model called "Test" and a test_controller with "scaffold :test" in it). What I get is: ---- Mysql::Error in Test#index Access denied for user ''''@''192.168.0.3'' (using password: NO) ---- Here''s what database.yml looks like: ---- development: adapter: mysql database: dbname host: 192.168.0.4 username: username password: somepassword ---- The database, user name and password are the same as the ones used to connect with "mysql". (and yeah, I restarted webrick after modifying the file) Any pointers appreciated, Cheers
Hasan Veldstra wrote:> > ---- > Mysql::Error in Test#index > > Access denied for user ''''@''192.168.0.3'' (using password: NO)Something''s not working right here - there is no username and password being passed to the MySQL connector.> Here''s what database.yml looks like: > > ---- > development: > adapter: mysql > database: dbname > host: 192.168.0.4 > username: username > password: somepassword > ---- > > The database, user name and password are the same as the ones used to > connect with "mysql". (and yeah, I restarted webrick after modifying > the file)So, you''re saying that connecting from your powerbook using the myql command line tool to the dbname database on the linux box using "username" / "somepassword" works OK? But that connecting from your powerbook using Rails to the dbname database on the linux box using "username" / "somepassword" does *not* work? One problem I''ve run into before is that database.yml is very sensitive to rogue white space (tabs, space, etc.). You might want to double check that your fileis "clean". One more longshot: you *are8 using the dev database, aren''t you? i.e. you''re not using -e production or similar? R. -- http://robinbowes.com If a man speaks in a forest, and his wife''s not there, is he still wrong?
> So, you''re saying that connecting from your powerbook using the myql > command line tool to the dbname database on the linux box using > "username" / "somepassword" works OK? But that connecting from your > powerbook using Rails to the dbname database on the linux box using > "username" / "somepassword" does *not* work?Yes, same host, same database name, user name & password. I''ve tried getting Rails connect to MySQL on localhost and that fails too with the same exception. (mysql command works fine again) I''ve also tried running the app with SQLite3 and it works fine so probably it''s the MySQL bindings. I''m running MySQL 4.1.10 and Rails 0.13.1. Any other ideas? Cheers
Hasan Veldstra wrote:>>So, you''re saying that connecting from your powerbook using the myql >>command line tool to the dbname database on the linux box using >>"username" / "somepassword" works OK? But that connecting from your >>powerbook using Rails to the dbname database on the linux box using >>"username" / "somepassword" does *not* work? >> >> > >Yes, same host, same database name, user name & password. > >I''ve tried getting Rails connect to MySQL on localhost and that fails >too with the same exception. (mysql command works fine again) I''ve >also tried running the app with SQLite3 and it works fine so probably >it''s the MySQL bindings. > >I''m running MySQL 4.1.10 and Rails 0.13.1. > >Any other ideas? >Alas, no. What do you log files say? Is there any useful output on the webrick console? When I started using Rails I also had problems with MySQL connectivity, so I switched to postgresql! R. -- http://robinbowes.com If a man speaks in a forest, and his wife''s not there, is he still wrong?
On Wed, Jul 20, 2005, Hasan Veldstra wrote:> ---- > Mysql::Error in Test#index > > Access denied for user ''''@''192.168.0.3'' (using password: NO) > ----Yeah. I think that you''ve hit the magical, wonderful OSX MySQL thingy. Try this: gem install mysql -- --with-mysql-config Note that this will require you have MySQL installed on the PowerBook as well, since you need the client libraries that come with MySQL. Probably better that way anyway, you can develop when you''re away from your linux box :) If you have problems with the compile, you may also need to switch to GCC 3.3: gcc_select 3.3 And when you''re done: gcc_select 4.0 This step was unneccessary for me, but if you run into troubles, you can try it. Ben
Alright, I got it working. Installation via gem with gem install mysql -- --with-mysql-config went ok, but it still did not work. (ruby -e "p require ''mysql''" printed a LoadError) So then I downloaded the package from http://www.tmtm.org/en/mysql/ruby/ and compiled/installed it as follows: 1. ruby extconf.rb --with-mysql-config 2. edit Makefile and remove all "-arch i386" 3. make 4. sudo make install (and yeah, sudo gem uninstall mysql first) Don''t know if the Tiger update I installed today had anything to do with it. Probably not. Thanks for help Robin & Ben Cheers