# Mysql connection problems

**URL:** <https://www.ruby-forum.com/t/mysql-connection-problems/50260>\
**Category:** Rails\
**Created:** [December 14, 2005, 5:10pm UTC](https://www.ruby-forum.com/t/mysql-connection-problems/50260 "2005-12-14T17:10:34Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![alexamat](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/bc8723/32.png) [@alexamat](https://www.ruby-forum.com/u/alexamat)\
**Post date:** [December 14, 2005, 5:10pm UTC](https://www.ruby-forum.com/t/mysql-connection-problems/50260/1 "2005-12-14T17:10:34Z")

</div>

Hi

hi i have a problem trying to connect to the mysql database when I do a  
rake it says: Access denied for user: ‘@localhost’ to database ‘’

My database.yml file is fine

Any ideas why this is happening

---

<div class="post-metadata">

**Author:** ![alexamat](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/bc8723/32.png) [@alexamat](https://www.ruby-forum.com/u/alexamat)\
**Post date:** [December 14, 2005, 5:36pm UTC](https://www.ruby-forum.com/t/mysql-connection-problems/50260/2 "2005-12-14T17:36:41Z")

</div>

On Wed, Dec 14, 2005 at 05:10:34PM +0100, Alex A. wrote:

> hi i have a problem trying to connect to the mysql database when I do a  
> rake it says: Access denied for user: ‘@localhost’ to database ‘’
> 
> My database.yml file is fine
> 
> Any ideas why this is happening

Can u connect to the database via

mysql -u [usename] -p [database]

?

It seems to be that your username und databasename is empty.

Greetings Thomas

---

<div class="post-metadata">

**Author:** ![alexamat](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/bc8723/32.png) [@alexamat](https://www.ruby-forum.com/u/alexamat)\
**Post date:** [December 14, 2005, 6:16pm UTC](https://www.ruby-forum.com/t/mysql-connection-problems/50260/3 "2005-12-14T18:16:58Z")

</div>

yes I can connect without a problem

Thomas J. wrote:

> On Wed, Dec 14, 2005 at 05:10:34PM +0100, Alex A. wrote:
> 
> > hi i have a problem trying to connect to the mysql database when I do a  
> > rake it says: Access denied for user: ‘@localhost’ to database ‘’
> > 
> > My database.yml file is fine
> > 
> > Any ideas why this is happening
> 
> Can u connect to the database via
> 
> mysql -u [usename] -p [database]
> 
> ?
> 
> It seems to be that your username und databasename is empty.
> 
> Greetings Thomas

---

<div class="post-metadata">

**Author:** ![alexamat](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/bc8723/32.png) [@alexamat](https://www.ruby-forum.com/u/alexamat)\
**Post date:** [December 14, 2005, 6:21pm UTC](https://www.ruby-forum.com/t/mysql-connection-problems/50260/4 "2005-12-14T18:21:52Z")

</div>

On 12/14/05, Alex A. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Hi
> 
> hi i have a problem trying to connect to the mysql database when I do a  
> rake it says: Access denied for user: ‘@localhost’ to database ‘’
> 
> My database.yml file is fine

Can you post your database.yml config (feel free to change your  
password to xxxxx).

---

<div class="post-metadata">

**Author:** ![alexamat](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/bc8723/32.png) [@alexamat](https://www.ruby-forum.com/u/alexamat)\
**Post date:** [December 14, 2005, 6:24pm UTC](https://www.ruby-forum.com/t/mysql-connection-problems/50260/5 "2005-12-14T18:24:53Z")

</div>

This seems to be related to the known issue surrounding mysql  
connections that  
came out in the last RC but was fixed in the very latest ActiveRecord.

Search the list archives for your error message - threads yesterday went  
through  
the fix (which was essentially to update to the new 1.0 release and  
force  
dependencies to be updated as well).

Quoting Thomas J. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> mysql -u [usename] -p [database]  
> removed\_email\_address@domain.invalid  
> [http://lists.rubyonrails.org/mailman/listinfo/rails](http://lists.rubyonrails.org/mailman/listinfo/rails)

Kevin B.  
[http://www.kbedell.com](http://www.kbedell.com)

“Imagination is more important than knowledge.”

- Albert Einstein

---

<div class="post-metadata">

**Author:** ![alexamat](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/bc8723/32.png) [@alexamat](https://www.ruby-forum.com/u/alexamat)\
**Post date:** [December 14, 2005, 7:10pm UTC](https://www.ruby-forum.com/t/mysql-connection-problems/50260/6 "2005-12-14T19:10:09Z")

</div>

. if possible update to the rails latest gems  
. if you have the option, update mysql to at least 4.1  
. what version of mysql are you using?  
. have you looked at previous threads?  
Subject: “Problem with mysql”  
Posted yesterday.  
And there are more threads that talk about this.  
. you may want to change the passwords to either the old- or new-style  
as a last resort if nothing else works for you. This has been  
discussed in a previous thread. I think here,  
[http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/169979](http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/169979)  
[http://comments.gmane.org/gmane.comp.lang.ruby.rails/33919](http://comments.gmane.org/gmane.comp.lang.ruby.rails/33919)

---

<div class="post-metadata">

**Author:** ![alexamat](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/bc8723/32.png) [@alexamat](https://www.ruby-forum.com/u/alexamat)\
**Post date:** [December 14, 2005, 8:06pm UTC](https://www.ruby-forum.com/t/mysql-connection-problems/50260/7 "2005-12-14T20:06:02Z")

</div>

> rake it says: Access denied for user: ‘@localhost’ to database ‘’

tow things that worked for me in the past:

1)instead of granting @localhost, try to grant @127.0.0.1 (bizarre, but  
worked for me, i just can’t remind the link where i read)

2)if using mysql 5, do check for old/new password style

good luck  
Andre
