简体   繁体   English

wordpress config-建立数据库连接本地主机时出错

[英]wordpress config - Error establishing a database connection localhost

I'm trying to get away from using Mamp, so have recently installed mysql, edited my vhosts and am attempting to run an instance of wordpress from a url that's not localhost. 我试图摆脱使用Mamp的麻烦,因此最近安装了mysql,编辑了我的虚拟主机,并试图从不是localhost的URL运行wordpress的实例。

I think I'm doing something wrong with mysql, as wordpress can't seem to access my database. 我认为mysql做错了,因为wordpress似乎无法访问我的数据库。

I get this error from wordpress - 我从wordpress收到此错误-

[2002] No such file or directory (trying to connect via unix:///var/mysql/mysql.sock) in in /Users/myusername/workspaces/wordpress/test/wp-includes/wp-db.php on line 1017

my wordpress config looks like this - 我的WordPress配置看起来像这样-

define('DB_NAME', 'test_db');
define('DB_USER', 'test_user');
define('DB_PASSWORD', 'test_password');
define('DB_HOST', 'localhost');

I'm accessing mysql from the terminal and am still finding my way around a recent move from windows, but I'm fairlry certain I've set up the user and db correctly. 我正在从终端访问mysql,但仍然可以从Windows的最近移动中找到自己的方式,但是我可以肯定地说,我已经正确设置了用户和数据库。

A solution would be great, but would also appreciate some tips on how I go about debugging a problem like this. 一个解决方案将是不错的选择,但同时也希望您能了解一些有关如何调试此类问题的提示。

mkdir /var/mysql

ln -s /tmp/mysql.sock /var/mysql/mysql.sock

Mac is not Unix. Mac不是Unix。 So try this. 所以尝试一下。

And for the tip: when you see an error like No such file or directory , you're missing a file or directory that the script expect to find. 提示:当您看到诸如No such file or directory的错误时,您将丢失脚本期望找到的文件或目录。 Eg if my solution is not working find where mysql.sock is and make a link pointing to /var/mysql/mysql.sock 例如,如果我的解决方案无法正常工作,请找到mysql.sock所在的位置,并建立指向/var/mysql/mysql.sock的链接

Apparently it's happening for Mac OS X 10.4.4+ 显然,这是在Mac OS X 10.4.4+上发生的

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM