Rost
Rost

Reputation: 53

Yii error when try to create model through gii

I have a error when trying to create model through Gii.Im going to this adress http://hostname/index.php?r=gii and have this error

Database Exception – yii\db\Exception

SQLSTATE[HY000] [1049] Unknown database 'yii2basic'
↵
Caused by: PDOException

SQLSTATE[HY000] [1049] Unknown database 'yii2basic'

in W:\XAMPP\htdocs\basic\vendor\yiisoft\yii2\db\Connection.php at line 602

Upvotes: 1

Views: 484

Answers (1)

ScaisEdge
ScaisEdge

Reputation: 133400

You should assign the proper value in you db.php config file

look in your basic\config directory for the file \db.php and then assigne the proper valur for the database, the username and the password

return [
   'class' => 'yii\db\Connection',
    'dsn' => 'mysql:host=localhost;dbname=yii2basic',
                                           ^^^ assign your correct dbname
    'username' => 'root',  // assign you  correct username  
     'password' => '',     // assign your password 
    'charset' => 'utf8',
 ];

Upvotes: 1

Related Questions