{"action":"created","issue":{"url":"https://api.github.com/repos/wp-cli/wp-cli/issues/1593","labels_url":"https://api.github.com/repos/wp-cli/wp-cli/issues/1593/labels{/name}","comments_url":"https://api.github.com/repos/wp-cli/wp-cli/issues/1593/comments","events_url":"https://api.github.com/repos/wp-cli/wp-cli/issues/1593/events","html_url":"https://github.com/wp-cli/wp-cli/issues/1593","id":53458885,"number":1593,"title":"Error establishing a database connection, even though `wp db query` works","user":{"login":"scribu","id":225715,"avatar_url":"https://avatars.githubusercontent.com/u/225715?v=3","gravatar_id":"","url":"https://api.github.com/users/scribu","html_url":"https://github.com/scribu","followers_url":"https://api.github.com/users/scribu/followers","following_url":"https://api.github.com/users/scribu/following{/other_user}","gists_url":"https://api.github.com/users/scribu/gists{/gist_id}","starred_url":"https://api.github.com/users/scribu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/scribu/subscriptions","organizations_url":"https://api.github.com/users/scribu/orgs","repos_url":"https://api.github.com/users/scribu/repos","events_url":"https://api.github.com/users/scribu/events{/privacy}","received_events_url":"https://api.github.com/users/scribu/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-01-05T22:55:50Z","updated_at":"2015-01-05T23:16:41Z","closed_at":"2015-01-05T23:16:41Z","body":"This happened in the process of setting up WP from scratch, using only WP-CLI.\r\n\r\n```\r\n$ wp cli version\r\nWP-CLI 0.17.1\r\n$ wp core version\r\n4.1\r\n$ wp db query 'SHOW TABLES';\r\n+-----------------------+\r\n| Tables_in_wp-server-8 |\r\n+-----------------------+\r\n| test                  |\r\n+-----------------------+\r\n$ wp core install\r\nError:\r\n<h1>Error establishing a database connection</h1>\r\n<p>This either means that the username and password information in your <code>wp-config.php</code> file is incorrect or we can't contact the database server at <code>localhost</code>. This could mean your host's database server is down.</p>\r\n<ul>\r\n\t<li>Are you sure you have the correct username and password?</li>\r\n\t<li>Are you sure that you have typed the correct hostname?</li>\r\n\t<li>Are you sure that the database server is running?</li>\r\n</ul>\r\n<p>If you're unsure what these terms mean you should probably contact your host. If you still need help you can always visit the <a href='https://wordpress.org/support/'>WordPress Support Forums</a>.</p>\r\n```"},"comment":{"url":"https://api.github.com/repos/wp-cli/wp-cli/issues/comments/68799900","html_url":"https://github.com/wp-cli/wp-cli/issues/1593#issuecomment-68799900","issue_url":"https://api.github.com/repos/wp-cli/wp-cli/issues/1593","id":68799900,"user":{"login":"scribu","id":225715,"avatar_url":"https://avatars.githubusercontent.com/u/225715?v=3","gravatar_id":"","url":"https://api.github.com/users/scribu","html_url":"https://github.com/scribu","followers_url":"https://api.github.com/users/scribu/followers","following_url":"https://api.github.com/users/scribu/following{/other_user}","gists_url":"https://api.github.com/users/scribu/gists{/gist_id}","starred_url":"https://api.github.com/users/scribu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/scribu/subscriptions","organizations_url":"https://api.github.com/users/scribu/orgs","repos_url":"https://api.github.com/users/scribu/repos","events_url":"https://api.github.com/users/scribu/events{/privacy}","received_events_url":"https://api.github.com/users/scribu/received_events","type":"User","site_admin":false},"created_at":"2015-01-05T23:16:41Z","updated_at":"2015-01-05T23:16:41Z","body":"It looks like it's some sort of misconfiguration on my machine. WP tries to connect to MySQL through a Unix socket and can't find it.\r\n\r\nThe quick fix was to change `wp-config.php`, from `define('DB_HOST', 'localhost');` to `define('DB_HOST', '127.0.0.1');`\r\n\r\nMore details here: http://stackoverflow.com/a/13771199/97998"}}