1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Mac OSXでのWordPress導入でデータベース接続エラー

Last updated at Posted at 2014-11-26

このドキュメントについて

Macのローカル環境でWordPressを動かそうとして、データベース接続エラーに遭遇した時の解決方法について書いています。

 PHP Warning:  mysql_connect(): No such file or directory in /Users/ashibuya/wordpress/wp-includes/wp-db.php on line 1409
[Tue Nov 25 15:53:36 2014] [error] [client ::1] PHP Notice: This XML document is invalid, likely due to invalid characters. XML error: Invalid character at line 23, column 26 in /Users/ashibuya/wordpress/wp-includes/class-simplepie.php on line 1446, referer: http://wordpress.sample.jp/wp-admin/

環境

  • MacOSX 10.9.5
  • PHP 5.4.35 (cli) (built: Nov 17 2014 06:06:49)
  • Server version: 5.6.21 MySQL Community Server (GPL)
  • WordPress 4.0.1

エラー内容

画面

WordPressのインストール画面の途中では「データベース接続エラー」の表示

apacheエラーログ

 PHP Warning:  mysql_connect(): No such file or directory in /Users/ashibuya/wordpress/wp-includes/wp-db.php on line 1409
[Tue Nov 25 15:53:36 2014] [error] [client ::1] PHP Notice: This XML document is invalid, likely due to invalid characters. XML error: Invalid character at line 23, column 26 in /Users/ashibuya/wordpress/wp-includes/class-simplepie.php on line 1446, referer: http://wordpress.sample.jp/wp-admin/

対処

MacOSXのMySQLではソケットファイルの位置がすこし悪いようです。
MySQLのセッティング、my.cnfで場所を変更するという方法もあるのですが、ここは、WordPressが参照しにいく場所にMySQLのソケットファイルをシンボリックリンクで置いてあげます。

cd /var 
sudo mkdir mysql
sudo chmod 755 mysql
cd mysql
ln -s /tmp/mysql.sock mysql.sock

参考

php - Warning: mysql_connect(): [2002] No such file or directory (trying to connect via unix:///tmp/mysql.sock) in - Stack Overflow

おまけ

東洋経済オンラインで「エンジニア夫婦のあるある日記」を連載中です

エンジニア夫婦のあるある日記

img_7aa46138cef6c956f55f35a3a6127f5587982.jpg

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?