Hello,
I’m new to Yii, and just now I’m studying “The Definitive Guide to Yii 2.0”, Working with Databases Chapter
I’ve created yii2basic database, db.php with the following content:
<?php
return [
'class' => 'yii\db\Connection',
'dsn' => 'mysql:host=127.0.0.1;dbname=yii2basic',
'username' => 'root',
'password' => '',
'charset' => 'utf8',
];
I have also created Country.php and CountryController.php , as described in the Guide, but, when I try to follow the link <MY_HOST_NAME>/frontend/web/index.php?r=country/index I get the following error:
[spoiler]Database Exception – yii\db\Exception
SQLSTATE[28000] [1045] Access denied for user ‘root’@‘localhost’ (using password: NO)
↵
Caused by: PDOException
SQLSTATE[28000] [1045] Access denied for user ‘root’@‘localhost’ (using password: NO)
in /home/<LOCAL_PATH>/Projects/www/yii/vendor/yiisoft/yii2/db/Connection.php at line 579
[/spoiler]
The example from the previous Chapter of the Guide works pretty fine, and so do Apache and MySQL. I can enter the latter using my root password.
So, what I’m doing wrong?
OS: Linux Mint 17
Yii Version: 2.0.3
PHP Version: 5.5.9-1ubuntu4.7
Apache Version: Apache/2.4.7 (Ubuntu)
MySQL Client API version: 5.5.41