简体   繁体   中英

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.

I think I'm doing something wrong with mysql, as wordpress can't seem to access my database.

I get this error from 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 -

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.

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. 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. Eg if my solution is not working find where mysql.sock is and make a link pointing to /var/mysql/mysql.sock

Apparently it's happening for Mac OS X 10.4.4+

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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