Custom Database Port

When creating a new site it is posisble to provide parameters for dbhost, dbname, dbpass etc. The connection seems to default to using the standard mysql port 3306/tcp.

When using managed database hosting (like that offered by digital ocean) they present the database on a non-standard port which cannot be changed. Is there a way to supply the port over which to communicate to the database host?

From the docs:
[–dbhost=]

While i have never tried it, it might be worth a shot at passing the custom port with the option above. Just use standard hostname:port naming. ex. mydatabasehost.com:2605

Whether this works or not, please respond back here. If it does then we can make a note in the title of the thread so that future searches find this answer. And for the inverse as well.

edit
Just to elaborate on the above comment.

ee site crate example.com --type=wp --dbhost=mydbhost.com:6606 --dbuser=youruser --dbpass=yourdbpass --dbname=yourdbname 

And for any site with an existing db that you move to a managed db, all you have to do is change the wp-config.php file for the site and set the database as per the Wordpress docs as mentioned here https://wordpress.org/support/article/editing-wp-config-php/#set-database-host

Help here on my topic please: Command Not Found

Thanks @freedog96150. I tested using the port number provided by the managed database instance after the database host name ie –dbhost=dbserver:dbport not long after I posted and it worked just fine.

Sorry its taken me so long to reply back to confirm that this works. :slight_smile: