yiic: CDbConnection failed to open the DB connection

1k Views Asked by At

My DB connection works perfectly in web application. But when I try the same settings in console application it fails (I wrote connection settings in console.php file).

CDbConnection failed to open the DB connection: SQLSTATE[28000] [1045] Access denied for user 'username'@'host' (using password: YES)

I can't solve problem for 4 hours. What might be wrong?

2

There are 2 best solutions below

0
On BEST ANSWER

if you want to connect to the same DB which you connect to in your web application then copy your 'db' => array(...) in config/main.php to config/console.php

0
On

In console.php change localhost to 127.0.0.1