# Access denied for user 'root'@'localhost' using password:NO

**URL:** <https://www.ruby-forum.com/t/access-denied-for-user-root-localhost-using-password-no/79320>\
**Category:** Rails\
**Created:** [December 14, 2006, 7:52am UTC](https://www.ruby-forum.com/t/access-denied-for-user-root-localhost-using-password-no/79320 "2006-12-14T07:52:43Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![vasan\_cec](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/258eb7/32.png) [@vasan\_cec](https://www.ruby-forum.com/u/vasan_cec)\
**Post date:** [December 14, 2006, 7:52am UTC](https://www.ruby-forum.com/t/access-denied-for-user-root-localhost-using-password-no/79320/1 "2006-12-14T07:52:43Z")

</div>

Hi Everyone,  
I developed an application in my system with Ruby, Rails,  
WEBrick and MySQL - everything installed in my system.  
First, i got this error  
“Access denied for user ‘root’@‘localhost’ using password:NO”  
But i found a quick fix, by installing MySQL without password and  
user name as “root”. And everything went fine.  
Now, my problem is - i want to upload my application and host it on  
net. But am getting the same error. Dont know how to fix it, i cant  
re-install mysql without password (will lead to security issue) or  
restart the ‘Apache’ server etc… since i read somewhere that if we  
change the “database.yml” file we should restart the Web Server (infact  
i was doing this in my system - restarting the WEBrick server)

Please anyone help me hosting my application.

Thanks in advance  
Regards,  
Vasanth

---

<div class="post-metadata">

**Author:** ![vasan\_cec](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/258eb7/32.png) [@vasan\_cec](https://www.ruby-forum.com/u/vasan_cec)\
**Post date:** [December 14, 2006, 8:01am UTC](https://www.ruby-forum.com/t/access-denied-for-user-root-localhost-using-password-no/79320/2 "2006-12-14T08:01:02Z")

</div>

have u updated the database.yml with u r database name and password?  
change it.

---

<div class="post-metadata">

**Author:** ![vasan\_cec](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/258eb7/32.png) [@vasan\_cec](https://www.ruby-forum.com/u/vasan_cec)\
**Post date:** [December 14, 2006, 8:02am UTC](https://www.ruby-forum.com/t/access-denied-for-user-root-localhost-using-password-no/79320/3 "2006-12-14T08:02:43Z")

</div>

Ya i have made all the changes in “database.yml” file…  
Still getting the same error ☹

---

<div class="post-metadata">

**Author:** ![vasan\_cec](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/258eb7/32.png) [@vasan\_cec](https://www.ruby-forum.com/u/vasan_cec)\
**Post date:** [December 14, 2006, 10:47am UTC](https://www.ruby-forum.com/t/access-denied-for-user-root-localhost-using-password-no/79320/4 "2006-12-14T10:47:19Z")

</div>

Hi, is the database and database.yml have the exact same userid and  
pass for access?

-Conrad

---

<div class="post-metadata">

**Author:** ![vasan\_cec](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/258eb7/32.png) [@vasan\_cec](https://www.ruby-forum.com/u/vasan_cec)\
**Post date:** [December 14, 2006, 12:31pm UTC](https://www.ruby-forum.com/t/access-denied-for-user-root-localhost-using-password-no/79320/5 "2006-12-14T12:31:28Z")

</div>

Try to check whether u given password as NO???

development:  
adapter: mysql  
database: ubac\_webfront\_development  
username: root  
password:  
host: localhost

check it to look like as above and then restart your webrick server.

---

<div class="post-metadata">

**Author:** ![vasan\_cec](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/258eb7/32.png) [@vasan\_cec](https://www.ruby-forum.com/u/vasan_cec)\
**Post date:** [December 14, 2006, 11:51am UTC](https://www.ruby-forum.com/t/access-denied-for-user-root-localhost-using-password-no/79320/6 "2006-12-14T11:51:16Z")

</div>

Ya both the database and database.yml have the exact userid and  
password…  
But i read somewhere that the Webserver should be restarted to take  
effect. Here in my case, thats impossible bcaz we have to host the  
application somewhere else. They wont restart the “Apache” server for  
our purpose… since many application are running there…  
If restarting the Webserver is the problem, then can anyone tell me  
another way to resolve this??

---

<div class="post-metadata">

**Author:** ![vasan\_cec](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/258eb7/32.png) [@vasan\_cec](https://www.ruby-forum.com/u/vasan_cec)\
**Post date:** [December 14, 2006, 1:31pm UTC](https://www.ruby-forum.com/t/access-denied-for-user-root-localhost-using-password-no/79320/7 "2006-12-14T13:31:50Z")

</div>

Ya everything is fine and good…  
But still the problem exists ☹  
do i need to restart “Apache” webserver??

---

<div class="post-metadata">

**Author:** ![vasan\_cec](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/258eb7/32.png) [@vasan\_cec](https://www.ruby-forum.com/u/vasan_cec)\
**Post date:** [December 14, 2006, 1:52pm UTC](https://www.ruby-forum.com/t/access-denied-for-user-root-localhost-using-password-no/79320/8 "2006-12-14T13:52:20Z")

</div>

Vasanthakumar C. wrote:

> Ya everything is fine and good…  
> But still the problem exists ☹  
> do i need to restart “Apache” webserver??

You should be able to just restart your fcgi processes - check out  
reaper.rb in the rails scripts directory.

---

<div class="post-metadata">

**Author:** ![vasan\_cec](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/258eb7/32.png) [@vasan\_cec](https://www.ruby-forum.com/u/vasan_cec)\
**Post date:** [December 14, 2006, 1:03pm UTC](https://www.ruby-forum.com/t/access-denied-for-user-root-localhost-using-password-no/79320/9 "2006-12-14T13:03:53Z")

</div>

Kiran Soumya wrote:

> Try to check whether u given password as NO???
> 
> development:  
> adapter: mysql  
> database: ubac\_webfront\_development  
> username: root  
> password:  
> host: localhost
> 
> check it to look like as above and then restart your webrick server.

I’m assuming you have the database.yml production settings filled in?

production:  
adapter: mysql  
database: production\_database\_name  
username: production\_user\_name  
password: production\_password  
host: localhost

If you are getting the same message are you running your application in  
production mode?

You might want to uncomment in the line in config/environment.rb:

# ENV[‘RAILS\_ENV’] = ‘production’

So it reads  
ENV[‘RAILS\_ENV’] = ‘production’
