<p>Try using a port variable:</p>

<pre><code>'STAGING' =&gt; array(
    'server' =&gt; 'localhost',
    'port' =&gt; '3939',
    'user' =&gt; 'myusername',
    'password' =&gt; '***********',
    'database' =&gt; 'mydatabase',
),
</code></pre>

CC BY-SA 3.0
2015-01-05T18:39:37.027Z
I've tried adding the variable to my config file without any luck. Do I need to add this variable anywhere else? I've been able to successfully connect to the database (and add content) with a MySQL database manager like Sequel Pro so I know the database is functioning.
RhealPoirier
CC BY-SA 3.0
2015-01-05T19:27:38.400Z
Perhaps try placing it in the default '*' block and see if it works to rule out the possibility that your 'staging' condition is not working properly. Assuming the database is on the same server as the config file, I would also try using `'server' => 'localhost',`
Douglas McDonald
CC BY-SA 3.0
2015-01-05T21:29:51.713Z
Using `'server' => 'localhost',` and `'port' => '3939',` worked for my situation.
RhealPoirier
CC BY-SA 3.0
2015-01-05T21:31:33.903Z
Great! I updated the answer.
Douglas McDonald
CC BY-SA 3.0
2015-01-05T17:28:09.907Z
2015-01-05T21:31:42.097Z
2015-01-05T21:31:42.097Z
Douglas McDonald
<p>I'm in the process of creating a multi-environment config and my client has set up a staging server with non-standard ports for the mysql server. I am unsure how to add the port number in the config file. I've tried the following with no success.</p>

<pre><code>'STAGING' =&gt; array(
        'server' =&gt; '123.456.789.123:3939',
        'user' =&gt; 'myusername',
        'password' =&gt; '***********',
        'database' =&gt; 'mydatabase',
    ),
</code></pre>

<p>I've been able to successfully connect the database when on a completely different server/mysql combo so I know that the config files work. </p>

<config><database>
Multi-Environment Config using port in database server
# Multi-Environment Config using port in database server

(Asked by: username_0 on 2015-01-05)

I'm in the process of creating a multi-environment config and my client has set up a staging server with non-standard ports for the mysql server. I am unsure how to add the port number in the config file. I've tried the following with no success.
'STAGING' => array(
        'server' => '123.456.789.123:3939',
        'user' => 'myusername',
        'password' => '***********',
        'database' => 'mydatabase',
    ),

I've been able to successfully connect the database when on a completely different server/mysql combo so I know that the config files work.

**Tags:** config, database

---

## 1 answers

### Answer by username_1 on 2015-01-05. Score: 4 | Accepted answer

Try using a port variable:
'STAGING' => array(
    'server' => 'localhost',
    'port' => '3939',
    'user' => 'myusername',
    'password' => '***********',
    'database' => 'mydatabase',
),

> **Comments:**
> **username_0**: I've tried adding the variable to my config file without any luck. Do I need to add this variable anywhere else? I've been able to successfully connect to the database (and add content) with a MySQL database manager like Sequel Pro so I know the database is functioning.  
> **username_1**: Perhaps try placing it in the default '*' block and see if it works to rule out the possibility that your 'staging' condition is not working properly. Assuming the database is on the same server as the config file, I would also try using `'server' => 'localhost',`  
> **username_0**: Using `'server' => 'localhost',` and `'port' => '3939',` worked for my situation.  
> **username_1**: Great! I updated the answer.  

---

