MySQL Cannot Connect with PHP in OSX
I think some of you might have problem connecting to MySQL with PHP(mysql_connect) in Max OS X if you configured MySQL5 with Darwin Ports. Most probably you will get these error message;
Warning: mysql_connect() [function.mysql-connect]: Can’t connect to local MySQL server through socket ‘/opt/local/var/run/mysql5/mysqld.sock’ (13) in /Users/paulooicongjen/myproject/web/info.php on line 10
Could not connect: Can’t connect to local MySQL server through socket ‘/opt/local/var/run/mysql5/mysqld.sock’ (13)
The error message is caused by the folder mode created by MySQL installation by default. To solve this problem, change your folder mode to 755 and restart apache.
cd /opt/local/var/run
sudo chmod 755 mysql5
sudo apachectl restart
It should works now!
Related posts:
- Install MySQL5 on Mac OSX With Darwin Port Before installing MySQL5, please be sure you have Darwin Port...
- How to Change MySQL Data Directory in Linux Centos By default Linux CentOS or other Linux Distro installation, MySQL...
- Reset MySQL Root Password Very often, once we didn’t log on to MySQL database...
- MySQL 5 Server Cannot Start on Apple Mac Leopard There were some problem during configuring MySQL5 Server on Leopard...
- Install MySQL5 Server on Apple Mac Leopard with MacPorts Previously I wrote a post on “installing postgresql 8.2 on...
- postgresql82-server compile error on Apple Leopard with Macports 1.5 I wasn’t able to compile postgresql82-server on my machine, it’s...
- TextMate: Creating New Project in Shell Instantly Been using TextMate recently, really loving it like hell. There...
- You Must Restart Your MacBook Now Apple Macbook Restart Error Message Got this error message from...
- MySQL Quick Installation on FreeBSD Quick installation of MySQL Database on FreeBSD Server. Make sure...
- OS X Lion Macports OS X Lion Macports, Can I upgrade from Snow Leopard?...
