Jump to content

Connecting to MySQL on a custom port?


THEK

Recommended Posts

Hi,

 

I'm trying to connect to a database on a port other than 3306 to create a database. Here's my connect code:

 

$connection = new MySQLi($host,$user,$pass)

 

But according to the PHP website it says I can lay the code out like so:

 

new MySQLi($host,$user,$pass,$database,$port)

 

But how do I specify the port without the database? I've tried just "" as the database but the connection still fails.

 

Any help would be much appreciated.

Link to comment
https://forums.phpfreaks.com/topic/253718-connecting-to-mysql-on-a-custom-port/
Share on other sites

you could set the host to "127.0.0.1:3307" or w/e port you want to use?

 

Dunno if that will work but it "should".

 

That was what I had but it said unknown host.

 

How about using null?

 

This worked perfectly. I was putting it in quotes but it only works without them.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.