MacOS10.10php不能连接mysql问题解决_MySQL
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了MacOS10.10php不能连接mysql问题解决_MySQL,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含1631字,纯文字阅读大概需要3分钟。
内容图文
![MacOS10.10php不能连接mysql问题解决_MySQL](/upload/InfoBanner/zyjiaocheng/580/a0ffe2cff7e4418ea7c6a92e9a22f43a.jpg)
用链接的方式解决了. 原文如下:
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 the .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 obviously 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!
内容总结
以上是互联网集市为您收集整理的MacOS10.10php不能连接mysql问题解决_MySQL全部内容,希望文章能够帮你解决MacOS10.10php不能连接mysql问题解决_MySQL所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。