Mac OS 10.10 php不能连接mysql问题解决
来源:互联网 发布:dao编程 编辑:程序博客网 时间:2024/06/06 03:51
php连接数据库都没问题,升级到10.10这后, 突然连接不上了. 这个问题放了很久, 今天突然搜索到一篇文章.
用链接的方式解决了. 原文如下:
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!
- Mac OS 10.10 php不能连接mysql问题解决
- mac os lion 上php连接mysql数据库不能使用使用localhost问题
- PHP连接MYSQL问题解决
- PHP不能连接Mysql
- php连接MySQL失败问题解决
- Mac Os X Yosemite 10.10.5 配置apache,php,mysql
- 在Mac OS X系统下用PHP连接MySQL数据库时的问题
- mysql 1130 远程不能连接问题解决
- php不能和MySQL连接
- Mac OS Apache+PHP+MySQL配置
- mac os x apache mysql php 配置
- Mac OS 下MySQL的Command not found的问题解决
- php无法连接mysql问题解决方法总结
- Mac OS连接Linux
- Mac OS X下MySQL 5.0的默认连接数
- mac os 上 安装 rails 连接 mysql server
- mac os x系统asp.net开发(连接mysql数据库)
- Mac OS 环境下 R语言连接MySQL方法
- Unix中C程序内存布局
- Memcached 结合nginx实现小文件存储方案
- 心静如水静如止水
- 创建者模式——抽象工厂模式(Abstract Factory)(3)
- 图像检索实战(1):Image retrieval using MatconvNet and pre-trained imageNet
- Mac OS 10.10 php不能连接mysql问题解决
- 中断下半部机制 - 软中断及tasklet
- QModelIndex 转换成QStandardItem
- 非阻塞connect编写方法介绍
- 编程珠玑感悟<1>
- 黑马程序员------7k月薪面试题-交通灯管理系统
- 第二章第三题
- 【hadoop】 3002-mapreduce程序统计单词个数示例
- 第四周 项目3 用对象数组操作长方柱类