# Driving me nuts! - Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

**URL:** <https://www.ruby-forum.com/t/driving-me-nuts-cant-connect-to-local-mysql-server-through-socket-tmp-mysql-sock-2/166753>\
**Category:** Rails\
**Created:** [April 29, 2009, 8:17am UTC](https://www.ruby-forum.com/t/driving-me-nuts-cant-connect-to-local-mysql-server-through-socket-tmp-mysql-sock-2/166753 "2009-04-29T08:17:29Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [April 29, 2009, 8:17am UTC](https://www.ruby-forum.com/t/driving-me-nuts-cant-connect-to-local-mysql-server-through-socket-tmp-mysql-sock-2/166753/1 "2009-04-29T08:17:29Z")

</div>

I had to put a new HD in, and now I’m reinstalling everything, and  
can’t get mysql to fully work. I can’t remember how I fixed it. I’ve  
searched everywhere online and can’t find anything.

when I try to use the \>mysql command I get this:

Can’t connect to local MySQL server through socket ‘/tmp/  
mysql.sock’ (2)

My first error came in installing mysql here:

> **[Dan Benjamin](https://danbenjamin.com)**
>
> Dan Benjamin's personal website.

It was this step that messed me up:  
cd /usr/local/mysql  
sudo ./bin/mysql\_install\_db --user=mysql  
sudo chown -R mysql ./var

I can cd the mysql folder, but when I run the second command I get  
this:

Installing MySQL system tables…  
090428 23:15:26 [ERROR] /usr/local/mysql/libexec/mysqld: Can’t find  
file: ‘./mysql/db.frm’ (errno: 13)  
ERROR: 1017 Can’t find file: ‘./mysql/db.frm’ (errno: 13)

I’ve been on this for hours. anyone know?

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [April 29, 2009, 9:06am UTC](https://www.ruby-forum.com/t/driving-me-nuts-cant-connect-to-local-mysql-server-through-socket-tmp-mysql-sock-2/166753/2 "2009-04-29T09:06:58Z")

</div>

On Wed, Apr 29, 2009 at 8:16 AM, removed\_email\_address@domain.invalid  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> My first error came in installing mysql here:  
> Installing MySQL system tables…  
> 090428 23:15:26 [ERROR] /usr/local/mysql/libexec/mysqld: Can’t find  
> file: ‘./mysql/db.frm’ (errno: 13)  
> ERROR: 1017 Can’t find file: ‘./mysql/db.frm’ (errno: 13)
> 
> I’ve been on this for hours. anyone know?

I’ve had this before, I installed mysql from an ubuntu package and  
suddenly it put the socket into /var/run/mysqld/mysqld.sock  
You can create or edit /etc/my.cnf and tell it where the socket file  
is created, just remember to add a line for each configuration group  
(i.e. [client], [mysqld] etc)  
You can also tell Rails where the socket is in database.yml

Andrew T.  
[http://ramblingsonrails.com](http://ramblingsonrails.com)  
[http://www.linkedin.com/in/andrewtimberlake](http://www.linkedin.com/in/andrewtimberlake)

“I have never let my schooling interfere with my education” - Mark Twain

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [April 29, 2009, 11:49am UTC](https://www.ruby-forum.com/t/driving-me-nuts-cant-connect-to-local-mysql-server-through-socket-tmp-mysql-sock-2/166753/3 "2009-04-29T11:49:27Z")

</div>

Wow, ok this solved it:

Instead of using:  
sudo ./bin/mysqld\_safe --user=mysql

I needed to use:  
sudo ./bin/mysql\_install\_db --user=mysql
