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 Solution to the error “Visual Studio Code can’t be opened because Apple cannot check it for malicious software” #2 How to add Read More Read Less Button using JavaScript? #3 How to check if radio button is checked or not using JavaScript? #4 Solution to “TypeError: ‘x’ is not iterable” in Angular 9 #5 PHP Login System using PDO Part 1: Create User Registration Page #6 How to uninstall Cocoapods from the Mac OS?

Recently Posted

#Apr 8 JSON.stringify() in JavaScript #Apr 7 Middleware in NextJS #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
You might also like these
How to float an image around texts?CSSA Quick Comparison of JOIN and Subquery in SQLSQL/MySQLPHP __construct() functionPHPSome EASY-to-Understand CSS media query examplesCSSHow to create a Star Ratings using CSS?CSSClearwater Seafoods – B2C in ChinaMiscellaneous