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
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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.