Solve the problem that Mac OS 10.10 php cannot connect to mysql, 10.10 mysql

Source: Internet
Author: User

Solve the problem that Mac OS 10.10 php cannot connect to mysql, 10.10 mysql

There is no problem connecting php to the database. After upgrading to 10.10, the connection suddenly fails. This problem has been put on for a long time. Today, I suddenly found an article.

Solved by link. The original Article is as follows:

So you installed Ubuntu, got all excited about developing your Rails application on it, and then...

No such file or directory - /tmp/mysql.sock)

No matter what you do, database connection doesn't work. You reinstall Rails (of course you installed it via "sudo apt-get rails", right ??), Reinstall MySql, recreate the database schema, change root's password, install Kubuntu instead of Ubuntu... But it doesn' t work.

The reason for this error is quite simple, really: somewhere along Ruby's Mysql driver, mysql socket is expected to exist at/tmp/mysql. sock. but that's not where it is in Ubuntu. if you take some time searching, you'll notice that. sock file is actually on/var/run/mysqld-and it's called mysqld. sock instead.

In fact, if you Google it, there is a closed bug entry on Rails 'tracking system regarding that problem, and the suggested solution there is to change your database. yml to add a link to the correct socket. something like:

production:  adapter: mysql  socket: /var/run/mysqld/mysqld.sock

Which is obviusly not a good idea, since you'll end up creating new projects, moving to a different OS or whatever-and everything will break again.

So I tried a small patchwork to fool mysql's driver, and then it works nicely:

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

That way you will actually HAVE a/tmp/mysql. sock file, as expected by mysql driver, and everything will connect just fine. Just like it's meant to be. Amen!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.