Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP Codeigniter : set Port Number for MySQL Configuration

Can you explain to me how to set port number for a Database configuration :

class MY_Model extends CI_Model 
{
    protected static $db2_loaded = false;
    protected static $db2 = false;
    function __construct() 
    {
        parent::__construct();
        if(($this->session->userdata('login_user')!=false) && !self::$db2_loaded) 
        { 
            self::$db2_loaded = true;
            $config['hostname'] = "localhost";      
            $config['username'] = "root";
            $config['password'] = "";
            $config['database'] = $this->session->userdata('bdd_compte');
            $config['dbdriver'] = "mysql";
            $config['dbprefix'] = "";
            $config['pconnect'] = TRUE;
            $config['db_debug'] = TRUE;
            $config['cache_on'] = FALSE;
            $config['cachedir'] = "";
            $config['char_set'] = "utf8";

            $config['dbcollat'] = "utf8_general_ci";
            self::$db2 = $this->load->database($config,TRUE);

        }
        $this->db = self::$db2;


    }
}

Any ideas how should I set a different port number

Thanks!

like image 486
AHméd Net Avatar asked Nov 03 '14 14:11

AHméd Net


1 Answers

Use the port key in database.php.

$db['default']['port'] = 5432;

OR

$db['default']['hostname'] = "mysqlhost.yourdomain.com:3310";  
like image 157
Pupil Avatar answered Nov 06 '22 23:11

Pupil