Can’t find mysqld.sock?

Over two days streamlined caught my attention. I tried it, got nothing but instead a lot of achings. That made various sorts of problems corrupting Rails. I’ll continue to be up with it and hope they can fix their bug lately in future. After all now my rest of Rails apps run well.

I don’t scare of connecting problem since I think I really got it worked out on me. But My Rails ultimately teased to me:

Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)

It can’t find out mysqld.sock though it perfectly run on early morning before I set up streamlined. So I edit /etc/my.cnf and change ’socket’ location in section to fix through this, but nothing happened. So I roughly

sudo ln -s  /var/run/mysqld/mysqld.sock /tmp/mysql.sock

mysqld.sock in /var/run/mysqld/ shares 755 mood. Then everything is ok! What a silent world.

That’s all~

12 Responses to “Can’t find mysqld.sock?”


  1. 1 Curtis Summers July 22, 2006 at 9:10 pm

    You can also specify the socket path in your rails database.yaml file:

    production:
    adapter: mysql

    socket: /path/to/mysql.sock

  2. 2 Zhenzhong Wang July 23, 2006 at 3:44 am

    Thank you Curtis!

    I did it but failed, ever. Either specifying path in /etc/mysql/my.cnf or adding socket section in database.yml that didn’t help somehow, so I have to try to make a link. To my surprise, it works.

    Anyway, Thank you for your comment here.

  3. 3 John L April 6, 2007 at 12:28 pm

    So in order of attempts i tried…
    1. Re-installing rails (assuming it would find the mysqld.sock)
    FAILED
    2. Copying mysqld.sock to /tmp/
    FAILED (couldn’t copy)
    3. Putting the socket: /path/to/mysqld.sock in database.yml
    FAILED
    4. Creating a link with ln -s /var/run/mysqld/mysqld.sock /tmp/mysql.sock
    WORKED!

    Thanks for the workaround.

  4. 4 Shravan May 18, 2007 at 5:40 am

    I tried by adding the line

    socket: /var/run/mysqld/mysqld.sock

    to the database.yml file and it worked perfect !!

    Thanks.

  5. 5 bayra December 5, 2007 at 4:37 pm

    i can’t database.yml file! how to edit?!!!

  6. 6 jonny March 21, 2008 at 5:35 am

    I’m so dumb, I had a # in my password

  7. 7 Christopher Maduro April 18, 2008 at 5:00 pm

    Thanks Shravan! I missed it, but the filename actually is not mysql.sock but mysqld.sock. Reading too fast i guess.

  8. 8 Rushyan January 17, 2009 at 5:45 am

    О, это что-то, недавно где-то уже о таком слышала. Ваше мнение имеет основание быть. Вы понимаете то, о чем пишите. Немного почитав, хотелось бы узнать больше.

  9. 9 Jesus Guifarro October 26, 2009 at 4:05 am

    me funciono!! gracias!

  10. 10 Артур Конев October 28, 2009 at 8:44 am

    Хех… :) Почаще пишите смайлики, а то всё так как будто все очень серъёзно :)

  11. 11 Родион Абдулов October 31, 2009 at 9:35 am

    Хм… что-то у меня ссылка не открывается, которую указали. Это у всех так?


  1. 1 Ubuntu, Rails, and mysql.sock Trackback on August 17, 2006 at 6:37 am

Leave a Reply




This personal blog of Zhenzhong Wang, is mainly about Ruby on Rails and my a little spark at a mere whim.

You can Subscribe to my blog here.

a