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', '127.0.0.1:1111' );
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', '127.0.0.1:/var/run/mysqld/mysqld.sock' );
// 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.
database hosting mysql pipes wp-admin wp-config