Inconsistent MySQL access behavior

I've run into a problem on my Mac PowerBook G4 related to MySQL access.
Everything works fine for migrations and script/server (read and write
to the development database), but get the following error with 'rake
test' and 'script/server':

    Mysql::Error: Access denied for user 'rails'@'localhost' (using
password: YES)

Any ideas on what is causing this?

My database.yml file is:

  adapter: mysql
  database: st_development
  host: localhost
  username: rails

  adapter: mysql
  database: st_test
  host: localhost
  username: rails

  adapter: mysql
  database: st_production
  host: localhost
  username: rails
  password: ******

$ gem query -n mysql

*** LOCAL GEMS ***

mysql (2.7)
    MySQL/Ruby provides the same functions for Ruby programs that the
    MySQL C API provides for C programs.
$ rails -v
Rails 1.1.6
$ ruby -v
ruby 1.8.5 (2006-08-25) [powerpc-darwin8.8.0]
$ mysql --version
mysql Ver 14.7 Distrib 4.1.20, for apple-darwin8.8.0 (powerpc) using
EditLine wrapper
$ uname -a
Darwin 8.8.0 Darwin Kernel Version 8.8.0: Fri
Sep 8 17:18:57 PDT 2006; root:xnu-792.12.6.obj~1/RELEASE_PPC Power
Macintosh powerpc