Make WordPress Core

Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#33842 closed defect (bug) (invalid)

wp-options.php ignores port for mysql when database is localhost

Reported by: carles_mateo's profile carles_mateo Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.3
Component: Bootstrap/Load Keywords: needs-codex
Focuses: Cc:


According to documentation ( this should work:
define( 'DB_HOST', 'localhost:3307' );

But instead, the port section is ignored and default mysql port is used.

But if I do:
define( 'DB_HOST', '' );

Then it works and connects to 3307.

I've checked with two different systems, with the last WP version (English).

Attachments (1)

wordpress-bug-terminal.png (56.6 KB) - added by carles_mateo 9 years ago.
Sample of the line in wp_config.php affected

Download all attachments as: .zip

Change History (3)

9 years ago

Sample of the line in wp_config.php affected

#1 @kitchin
9 years ago

  • Keywords needs-codex added
  • Resolution set to invalid
  • Status changed from new to closed

PHP treats localhost differently than

Whenever you specify "localhost" or "localhost:port" as server, the MySQL client library will override this and try to connect to a local socket (named pipe on Windows). If you want to use TCP/IP, use "" instead of "localhost". If the MySQL client library tries to connect to the wrong local socket, you should set the correct path as in your PHP configuration and leave the server field blank.
See also the comment at

I'll take a go at the codex.

Last edited 9 years ago by kitchin (previous) (diff)

#2 @ocean90
9 years ago

  • Milestone Awaiting Review deleted
Note: See TracTickets for help on using tickets.