# Access denied for root@localhost

**URL:** <https://www.ruby-forum.com/t/access-denied-for-root-localhost/144238>\
**Category:** Rails\
**Created:** [July 27, 2008, 7:59am UTC](https://www.ruby-forum.com/t/access-denied-for-root-localhost/144238 "2008-07-27T07:59:08Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![joeyboy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/edb3f5/32.png) [@joeyboy](https://www.ruby-forum.com/u/joeyboy)\
**Post date:** [July 27, 2008, 7:59am UTC](https://www.ruby-forum.com/t/access-denied-for-root-localhost/144238/1 "2008-07-27T07:59:08Z")

</div>

hi!

when i run this command: rake db:schema:load i get:

access denied for root@localhost

iâ€™m 101% sure i entered the correct login name and password in  
config\database.yml. i can go inside mysql environment using the  
credentials in database.yml. i also tried to run ruby script/console and  
i was able to get to the development environment.

are there any config file that i missed?

thank you!

---

<div class="post-metadata">

**Author:** ![joeyboy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/edb3f5/32.png) [@joeyboy](https://www.ruby-forum.com/u/joeyboy)\
**Post date:** [July 27, 2008, 8:44am UTC](https://www.ruby-forum.com/t/access-denied-for-root-localhost/144238/2 "2008-07-27T08:44:46Z")

</div>

Hi, can you access the database from the command?  
-Conrad

On Sat, Jul 26, 2008 at 10:59 PM, Joey B.  
\<removed\_email\_address@domain.invalid

---

<div class="post-metadata">

**Author:** ![joeyboy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/edb3f5/32.png) [@joeyboy](https://www.ruby-forum.com/u/joeyboy)\
**Post date:** [July 27, 2008, 9:15am UTC](https://www.ruby-forum.com/t/access-denied-for-root-localhost/144238/3 "2008-07-27T09:15:29Z")

</div>

Conrad T. wrote:

> Hi, can you access the database from the command?  
> -Conrad

hi!

like if i do?

mysql -u root -p

then yes. same user and password in database.yml file. i can’t quite  
figure out what is missing in my rails app.

thanks.

---

<div class="post-metadata">

**Author:** ![joeyboy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/edb3f5/32.png) [@joeyboy](https://www.ruby-forum.com/u/joeyboy)\
**Post date:** [July 27, 2008, 9:15am UTC](https://www.ruby-forum.com/t/access-denied-for-root-localhost/144238/4 "2008-07-27T09:15:45Z")

</div>

Looks like a mysql issue…

try this:

mysql\> show grants for root@localhost;

Should give you something like this:

±--------------------------------------------------------------------  
+  
| Grants for root@localhost  
|  
±--------------------------------------------------------------------  
+  
| GRANT ALL PRIVILEGES ON _._ TO ‘root’@‘localhost’ WITH GRANT OPTION  
|  
±--------------------------------------------------------------------  
+  
1 row in set (0.02 sec)

This is root access to _._ all databases with NO password… if there  
is an identified by then you have a password…

---

<div class="post-metadata">

**Author:** ![joeyboy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/edb3f5/32.png) [@joeyboy](https://www.ruby-forum.com/u/joeyboy)\
**Post date:** [July 27, 2008, 9:43am UTC](https://www.ruby-forum.com/t/access-denied-for-root-localhost/144238/5 "2008-07-27T09:43:48Z")

</div>

Looks like an issue with mysql grants too me.

When you access mysql from the command line and run \s what does it  
say under current user? root@localhost? or removed\_email\_address@domain.invalid ?

Maye you have access to “see” the database but doing schema load you  
might be missing the correct CREATE,INSERT grants?

Here would be the give all access command:

grant all on your\_database.\* to ‘root’@‘localhost’ identified by  
‘password’;

---

<div class="post-metadata">

**Author:** ![joeyboy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/edb3f5/32.png) [@joeyboy](https://www.ruby-forum.com/u/joeyboy)\
**Post date:** [July 27, 2008, 6:14pm UTC](https://www.ruby-forum.com/t/access-denied-for-root-localhost/144238/6 "2008-07-27T18:14:38Z")

</div>

hi heimdull,

thank you for your time. i did as you suggested but still can’t get  
through this problem.

as mentioned, i am able to go to mysql environment using the same user  
name and password in config/database.yml. likewise, i can also go inside  
rails’ development environment through ruby script/server.

what’s more puzzling is if i generate a new app, (ie. rails testap),  
then make config/database.yml similar with the other, it does work fine.  
i should also mention that i’m trying to install coupa.

any other ideas why a rake db:schema:load would return the access denied  
error?

i noticed that sometimes the error messages returned by rake(?) does not  
actually relate to the actual problem. so this could be one of those.

thank you!
