1

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?

arfname
  • 379
  • 1
  • 4
  • 10

2 Answers2

0

In console.php change localhost to 127.0.0.1

Chalist
  • 3,160
  • 5
  • 39
  • 68
0

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