Mac OS 10.10 php不能连接mysql问题解决

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!

时间: 2024-10-03 07:20:43

Mac OS 10.10 php不能连接mysql问题解决的相关文章

在Mac OS X 10.8中配置Apache + PHP + MySQL

在Mac OS X 10.8中配置Apache+PHP+MySQL的内容包括: 配置Apache 配置PHP 安装MySQL 配置PHPAdmin 设置数据库默认字符集 一. 配置Apache 1. 启动Apache 打开终端,输入: sudo apachectl start 打开浏览器,输入: http://localhost 应该可以看到”It works!“的页面,该页面位于/Library/WebServer/Documents/目录下,这是Apache的默认根目录. 2. 配置用户访问

Apache, MySQL, phpMyAdmin在Mac OS X 10.9 下的配置

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Command: mysql_secure_installation +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMEND

VMware Workstation11.0安装Mac OS X 10.10最完整指南(包含所需所有资源下载)

前言说明:最近换了新的电脑,配置好很多了,想装下虚拟机来玩下IOS,其中也遇到了几个大坑,现在刚完全装好,把所有步骤以及资源整合到一处,后面的朋友可以避免浪费很多无谓的百度时间. ""我先把使用到的程序以及版本说明下,因为这非常总要,使用虚拟机安装mac,其实就是装黑苹果,这要依赖很多破解工具,但这些工具都是有版本支持的.我这些版本装的没问题,但是你如果下载网上其他版本,我就不能确保一定没问题了,只能是自己试了."" VMware 11.0 永久不过期激活密钥 1F

Swift之 vm10虚拟机安装Mac OS X10.10教程

VM10装Mac OS X 10.9.3及更新到Mac OS X 10.10,让你的windows也能玩Swift . 近期WWDC放出终极大招--新的编程语言Swift(雨燕),导致一大波程序猿的围观和跃跃欲试. 当然了,工欲善其事,必先利其器,所以对于那些没有Mac又想要尝鲜的小伙伴肯定非常为难.可是,请放心,本文教你怎样在Windows下也能体验Mac的滋味.当然咯,最基本的还是体验新的语言Swift.好了话不多说,直接開始,贴图比較多,耐心等待图的刷出. 基本步骤 2.1. 虚拟机的安装

WMware 10 上安装Mac OS X 10.9 系统的正确方法

最近需要在iPad上做一个App,于是想在虚拟机中安装一个OS X 10.9试用一下.经过几十次的尝试趟过很多坑后,终于找到了在WMware 10 上安装Mac OS X 10.9 系统的正确方法.本方法不需要什么U盘,而且由于所有操作都在硬盘上,所以速度也会很快. 需要准备的工具和文件如下: VMware-workstation-full-10.0.1-1379776.exe unlock-all-v130.zip Install OS X Mavericks.dmg(大小为 4.94G) U

VMware 11完全安装Mac OS X 10.10

引用原文如下: VMware 11安装Mac OS X 10.10_百度经验 http://jingyan.baidu.com/article/ff411625b9011212e48237b4.html VM11安装Mac OS X 10.10 工具/原料 1.VMware Workstation 11 2.unlocker 203(for OS X 插件补丁) 3.Mac OS X 10.10镜像 方法/步骤 一.下载以上文件 1. 软件百度VMware Workstation 11 下载即可

Windows下虚拟机安装Mac OS X —– VM12安装Mac OS X 10.11

______________________________________________________________________________________________________________________________________________________________________________________________________________________ 注:本文来源:csdn:N的专栏.<Windows下虚拟机安装Mac

【转】VMware 11安装Mac OS X 10.10 及安装Mac Vmware Tools.

原文网址:http://www.cnblogs.com/Anand/p/4483727.html 先上一张效果图兴奋一下,博主穷屌丝一个,只能通过虚拟黑苹果体验下高富帅的生活,感觉超爽的,废话不多说的,直接上图了! 目录: 1.安装所需软件下载: 2.Mac OS X10.10 安装基本步骤: 3.Vmware Tools 安装步骤: 4.查看苹果系统位数: 1.安装所需软件下载: 百度云盘共享  链接:http://pan.baidu.com/s/1hq099Ow 密码:8air 包含有虚拟机

vm10虚拟机安装Mac OS X10.10教程[转]

所需软件vm10虚拟机安装苹果Mac10.9系统(带工具)http://www.helloswift.com.cn/swiftdown/soft/2014/0608/3095.html 基本步骤 2.1. 虚拟机的安装 2.2. 插件安装 2.3. Mac OS X 10.9.3的安装 2.4. VMTool以及Darwin6.0.3的安装 2.5. 设置共享文件夹 2.6 . 升级Mac OS X Yosemite 其他的一些tips 后续 一.所需软件 VMware Workstation

Mac OS X 10.9.4 安装全文索引 Coreseek-3.2.14稳定版 问题及解决

根据coreseek官方文档安装: http://www.coreseek.cn/products-install/install_on_macosx/ (1)在安装mmseg过程中,进行make操作的时候,突然报了以下错误信息: n file included from css/ThesaurusDict.cpp:6: ../src/css/ThesaurusDict.h:12:17: error: expected namespace name using namespace __gnu_c