# Path for Mysql

**URL:** <https://www.ruby-forum.com/t/path-for-mysql/119631>\
**Category:** Rails\
**Created:** [November 8, 2007, 6:52pm UTC](https://www.ruby-forum.com/t/path-for-mysql/119631 "2007-11-08T18:52:38Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![tobyr](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ebca7d/32.png) [@tobyr](https://www.ruby-forum.com/u/tobyr)\
**Post date:** [November 8, 2007, 6:52pm UTC](https://www.ruby-forum.com/t/path-for-mysql/119631/1 "2007-11-08T18:52:38Z")

</div>

On my RoR server (which I don’t have root access to) there are two  
instances of mysql (4.0.x and 5.0.x). My database has been created in  
the 5.0.x instance - I can log in manually OK (so I’ve got the correct  
username and passowrd) but my RoR keeps getting denied access.

/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active\_record/vendor/mysql.rb:523:in  
`read’: Access denied for user: ‘tobyr@localhost’ (Using password: YES)  
(Mysql::Error)

I think it may be a path issue - what do I need to do to point Ruby at  
the right instance of mysql? I assume it is config/database.yaml but  
I’m not sure what to add or change.

thanks in advance

---

<div class="post-metadata">

**Author:** ![tobyr](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ebca7d/32.png) [@tobyr](https://www.ruby-forum.com/u/tobyr)\
**Post date:** [November 8, 2007, 6:55pm UTC](https://www.ruby-forum.com/t/path-for-mysql/119631/2 "2007-11-08T18:55:06Z")

</div>

On 8 Nov 2007, at 17:52, Toby R. wrote:

> (Mysql::Error)
> 
> I think it may be a path issue - what do I need to do to point  
> Ruby at  
> the right instance of mysql? I assume it is config/database.yaml but  
> I’m not sure what to add or change.

It’s going to either be the port on which you connect to the mysql  
server or the path to the socket file.

Fred

---

<div class="post-metadata">

**Author:** ![tobyr](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ebca7d/32.png) [@tobyr](https://www.ruby-forum.com/u/tobyr)\
**Post date:** [November 8, 2007, 8:32pm UTC](https://www.ruby-forum.com/t/path-for-mysql/119631/3 "2007-11-08T20:32:18Z")

</div>

when you say you can log in locally what are you using to log in.  
command line mysql or a client like cocoamysql?  
try using tobyr as username and 127.0.0.1 as host instead of localhost

---

<div class="post-metadata">

**Author:** ![tobyr](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ebca7d/32.png) [@tobyr](https://www.ruby-forum.com/u/tobyr)\
**Post date:** [November 8, 2007, 8:52pm UTC](https://www.ruby-forum.com/t/path-for-mysql/119631/4 "2007-11-08T20:52:49Z")

</div>

OK, I found the “port: XXXX” config setting, but unfortunately it didn’t  
fix the problem. The strange thing is, _regardless_ of the port setting  
I seem to get the same error message - I would have assumed that using a  
bogus port number would give a different error message …

regards  
Toby

Toby R. wrote:

> Hi Fred,  
> Sounds promising - how do I tell Ruby which port to use? (There  
> appears to be just one ‘mysql.sock’, in /tmp/mysl.sock, and that’s what  
> the database.yaml is already pointing at).
> 
> /toby
> 
> Frederick C. wrote:
> 
> > On 8 Nov 2007, at 17:52, Toby R. wrote:
> > 
> > > (Mysql::Error)
> > > 
> > > I think it may be a path issue - what do I need to do to point  
> > > Ruby at  
> > > the right instance of mysql? I assume it is config/database.yaml but  
> > > I’m not sure what to add or change.
> > 
> > It’s going to either be the port on which you connect to the mysql  
> > server or the path to the socket file.
> > 
> > Fred

---

<div class="post-metadata">

**Author:** ![tobyr](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ebca7d/32.png) [@tobyr](https://www.ruby-forum.com/u/tobyr)\
**Post date:** [November 8, 2007, 8:36pm UTC](https://www.ruby-forum.com/t/path-for-mysql/119631/5 "2007-11-08T20:36:47Z")

</div>

Hi Fred,  
Sounds promising - how do I tell Ruby which port to use? (There  
appears to be just one ‘mysql.sock’, in /tmp/mysl.sock, and that’s what  
the database.yaml is already pointing at).

/toby

Frederick C. wrote:

> On 8 Nov 2007, at 17:52, Toby R. wrote:
> 
> > (Mysql::Error)
> > 
> > I think it may be a path issue - what do I need to do to point  
> > Ruby at  
> > the right instance of mysql? I assume it is config/database.yaml but  
> > I’m not sure what to add or change.
> 
> It’s going to either be the port on which you connect to the mysql  
> server or the path to the socket file.
> 
> Fred

---

<div class="post-metadata">

**Author:** ![tobyr](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ebca7d/32.png) [@tobyr](https://www.ruby-forum.com/u/tobyr)\
**Post date:** [November 8, 2007, 8:46pm UTC](https://www.ruby-forum.com/t/path-for-mysql/119631/6 "2007-11-08T20:46:07Z")

</div>

Hi Adam,  
It’s the CLI that works:

bash-2.05$ /usr/local/mysql-5.0.22/bin/mysql -u tobyr -p  
Enter password:  
Welcome to the MySQL monitor. Commands end with ; or \g.  
Your MySQL connection id is 41 to server version: 5.0.22-log

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the buffer.

mysql\>

…

Tried with “host: 127.0.0.1” but no joy. Thanks for the suggestion  
though.

/toby

Adam J. wrote:

> when you say you can log in locally what are you using to log in.  
> command line mysql or a client like cocoamysql?  
> try using tobyr as username and 127.0.0.1 as host instead of localhost
