Welcome Guest, Not a member yet? Register   Sign In
Coneccting to a database using MySQL port
#1

[eluser]Carlton[/eluser]
Hey,

I checked the documentation for the DB class and it mentions that port support when connecting to a DB is only supported when using the postgre driver type.
Is there a reason for not including it for mysql/mysqli or is it just a case of not getting round to it.

I checked the file at system/database/drivers/mysqli/mysqli_driver.php and noticed that within the 'db_connect' function you can add two extra parameters to 'mysqli_connect' (dbname and port) and it seems to work ok.

I wondered if anyone has attempted something similar or could explain why the ports are not supported just yet.

Thanks....

C
#2

[eluser]Unknown[/eluser]
I was able to resolve this by setting the default port in the php.ini file used by MAMP:

Code:
mysql.default_port = 8889

If you haven't made changes to the php.ini files yet, you can get to them by going to the File->Edit Template menu in MAMP.

I'm using MySQL and it seemed to use the default port just fine.
#3

[eluser]Unknown[/eluser]
Not sure if this is exactly what you're talking about, or if it's too obvious, but you can specify a MySQL port in system/application/config/database.php on the following line:

Code:
$db['default']['hostname'] = "mysqlhost";

You can specify a (non-default) port for MySQL to connect to using the full MySQL hostname, like this:

Code:
$db['default']['hostname'] = "mysqlhost.yourdomain.com:3310";

I figured this out after discovering I didn't have permission to edit php.ini on my webserver.




Theme © iAndrew 2016 - Forum software by © MyBB