configuring database connection in Yii framework

2019-03-27 16:47发布

In the main.php file of the Yii framework, there are some configuration options. This is how it sets up mysql

'db'=>array(
            'connectionString' => 'mysql:host=localhost;dbname=testdrive',
            'emulatePrepare' => true,
            'username' => 'root',
            'password' => 'root',
            'charset' => 'utf8',
        ),

On my MAMP system, I have to specify the port as 8889. How would I add it into this?

thanks

标签: php mysql yii
2条回答
倾城 Initia
2楼-- · 2019-03-27 16:53

can you not add it here to your connectionString

'connectionString' => 'mysql:host=localhost;dbname=testdrive;port=8889',

查看更多
欢心
3楼-- · 2019-03-27 17:11

I added the port like this and it seems to work

'db'=>array(
            'connectionString' => 'mysql:host=localhost;port=8889;dbname=testdrive',
            'emulatePrepare' => true,
            'username' => 'root',
            'password' => 'root',
            'charset' => 'utf8',
        ),
查看更多
登录 后发表回答