Yii Framework Forum

Error trying to connect to the database


(Duugabs) #1

I have database named mydata:

I get the following error after clicking on Model Generator

---- CDbConnection failed to open the DB connection: SQLSTATE[42000] [1049] Unknown database ’ mydata’ —

Can somebody help

This is how i configured my main.php

	// uncomment the following to use a MySQL database


	


	     'db'=>array(


		'connectionString' => 'mysql:host=localhost;dbname= mydata',


		'emulatePrepare' => true,


		'username' => 'username',


		'password' => 'password',


		'charset' => 'utf8',


		'tablePrefix' => 'tbl_',


	),

(Charlespick) #2

you have a space in your connection string…


(Duugabs) #3

Ooh thanks man, it works. Thanks very much.


(LIMBASIYA MILAN AJAY KUMAR) #4

SQLSTATE[HY000] [1049] Unknown database ‘yii2advanced’

i have got this error please give me solitions