Part of the EllisLab Network
   
 
Connecting to MySQL5 with non-standard port
Posted: 20 November 2006 05:01 PM   [ Ignore ]  
Summer Student
Total Posts:  1
Joined  11-20-2006

I was unable to connect to MySQL 5 on port 3307

Database is hosted on mysql5.mydomain.co.uk on port 3307. I am using mysql5, PHP 5.1.4 & mysqli
I could connect to my database using MySQL Admin using the above hostname & port, with the same username, password & dbname

When I attempted to connect with CI using mysql5.mydomain.co.uk:3307 as the hostname I got the error message:
  Message: mysqli_connect() [function.mysqli-connect.php]: (HY000/2005): Unknown MySQL server host ‘mysql5.mydomain.co.uk:3307’ (11004)

Leaving off the port suffix gave:
  Message: mysqli_connect() [function.mysqli-connect.php]: (28000/1045): Access denied for user ‘xxxxx’@‘85.13.212.2’ (using password: YES)

Eventually fixed this by adding $db[‘mydb’][‘port’] to /config/database.php and amending mysqli_driver.php as below:

  function db_connect()
  {
      return @ mysqli_connect($this->hostname, $this->username, $this->password, $this->database, $this->port);
  }

Hope this is helpful to others

Profile
 
 
Posted: 05 January 2007 02:13 PM   [ Ignore ]   [ # 1 ]  
Summer Student
Total Posts:  5
Joined  09-12-2006

Adding the port to the database config file needs to done for the release version.  I had a similar issue (I run two different mysql instances on different ports on the same machine).

Profile
 
 
Posted: 24 March 2007 09:47 AM   [ Ignore ]   [ # 2 ]  
Summer Student
Total Posts:  1
Joined  03-24-2007

Intercept, I did exactly the same, earlier spending like 2 hours looking for the cause of the problem.  I think CI should have “port” variable in the database config file by default.

Profile
 
 
   
 
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 719, on June 06, 2008 10:16 AM
Total Registered Members: 66409 Total Logged-in Users: 25
Total Topics: 84747 Total Anonymous Users: 0
Total Replies: 454806 Total Guests: 210
Total Posts: 539553    
Members ( View Memberlist )
Newest Members:  captainredmuffquinodligtharttechsivamDjordjesammozzazodman23mbsaarchaicharibok