Yogesh Chauhan's Blog

How to add MySQL alternate port and sockets/pipes in WordPress?

in WordPress on December 27, 2021

Read more about database configurations in this post:

How to update database configurations in WordPress?

We learned about setting up a database host in that post.

Let’s explore more setting in case you need to do that.

How to set MySQL alternate port?

You need change the value of the DB_HOST in wp-config for setting up a host. With the same line of code, you can also set an alternate port. Of course, all changed are need to be made in wp-config.php file.

This is how you can set MySQL alternate port for localhost:

define( 'DB_HOST', '' );

or you can literally use the word localhost instead of an ip address. It works many times depending on your machine configurations.

define( 'DB_HOST', 'localhost:1111' );

Hosts such as Dreamhost has a specified MySQL servers. In that case, you can set the port like this:

define( 'DB_HOST', 'mysql.example.com:1111' );

Replace 1111 with the port number provided by your server host in all the cases above.

MySQL sockets or pipes

For the hosts that uses Unix sockets or pipes, set DB_HOST value like this:

define( 'DB_HOST', '' );
// or define( 'DB_HOST', 'localhost:/var/run/mysqld/mysqld.sock' );
// or define( 'DB_HOST', 'example.tld:/var/run/mysqld/mysqld.sock' );

You need to replace /var/run/mysqld/mysqld.sock with the socket or pipe information provided by your host.

Read more about it on WordPress documentation.

Most Read

#1 How to check if radio button is checked or not using JavaScript? #2 How to add Read More Read Less Button using JavaScript? #3 Solution to “TypeError: ‘x’ is not iterable” in Angular 9 #4 How to uninstall Cocoapods from the Mac OS? #5 PHP Login System using PDO Part 1: Create User Registration Page #6 How to Use SQL MAX() Function with Dates?

Recently Posted

#Jan 17 4 advanced ways to search Colleague #Jan 16 Colleague UI Basics: The Search Area #Jan 16 Colleague UI Basics: The Context Area #Jan 16 Colleague UI Basics: Accessing the user interface #Jan 14 How to display a student’s individual transcript in Colleague? #Jan 11 How to install PuTTY on a MacOS?
You might also like these
How to display a student’s individual transcript in Colleague?ColleagueAdd animated hamburgers menu using Hamburgers collection on GitHubCSSRecursion in JavaScriptJavaScriptFive common features of Angular template syntax (with examples)Angular@use rule in SCSS (Sass)SCSSHow to verify your domain in Google Console with a TXT record?Miscellaneous