problem in connecting to Mysql

I am using gii and trying to generate Model class through Model Generator, unexpectedly i am not able to connect to MySql.

My connection string goes like this


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

		'emulatePrepare' => true,

		'username' => 'root',

		'password' => '',

		'charset' => 'utf8',


and i have 2 tables for the database.

When i type the table name in in Model Generator text field and then click on Preview, it showing the below message.

This webpage is not available.

The webpage at /artist/index.php?r=gii/model might be temporarily down or it may have moved permanently to a new web address.

I am also running different php applications on the same server which they are speaking to MySql.

I am not able to guess what the exact error is,Could some one guide on this.

Thanks in advance,


look like all OK, think at the DB maybe server down

This doesn’t look like a database connection problem.

Does your directory structure look like this?




With DB error you would get something like this before you even see the gii interface:

DB Server down:

CDbConnection failed to open the DB connection: SQLSTATE[HY000] [2003] Can’t connect to MySQL server on ‘localhost’ (10061)

Wrong Access Details:

CDbConnection failed to open the DB connection: SQLSTATE[28000] [1045] Access denied for user ‘user’@‘localhost’ (using password: YES)

check your gii configuration:

return array(





        'password'=&gt;'pick up a password here',

        // 'ipFilters'=&gt;array(...a list of IPs...),

        // 'newFileMode'=&gt;0666,

        // 'newDirMode'=&gt;0777,




I thought the config may be wrong but I doubt the gii interface would show unless it was set.

I’m thinking a path/route problem.

My config file goes like below i am using Yii 1.1.6

return array(


'name'=&gt;'My Web Application',

// preloading 'log' component


// autoloading model and component classes






	// uncomment the following to enable the Gii tool





	 	// If removed, Gii defaults to localhost only. Edit carefully to taste.





// application components



		// enable cookie-based authentication



	// uncomment the following to enable URLs in path-format













		'connectionString' =&gt; 'mysql:'.dirname(__FILE__).'/&#46;&#46;/data/testdrive.db',



	// uncomment the following to use a MySQL database



		'connectionString' =&gt; 'mysql:host=localhost;dbname=artist_paintings',

		'emulatePrepare' =&gt; true,

		'username' =&gt; 'root',

		'password' =&gt; '',

		'charset' =&gt; 'utf8',




		// use 'site/error' action to display errors








				'levels'=&gt;'error, warning',


			// uncomment the following to show log messages on web pages









// application-level parameters that can be accessed

// using Yii::app()-&gt;params['paramName']


	// this is used in contact page



My directory structure is like this D:\xampp\htdocs\artist_new\protected\config

Could some one help me out on this.

For xamp you have to specify the socket.







Find where is your mysql.sock and change the config main accordingly.

The clue is in the directory strucure and the url being called.

Remember this error:

The url is really


and not


Note the ‘artist’ part.

Somehow the generated link is incorrect.

In Xampp i didn’t find any file like mysql.sock.

I have two application



i am getting the same issue in both applications

I use Mamp on mac at home, and for work properly I have to configurate this unix-socket.

Make some search in the blog, maybe you will find something, if you cannot solve this evening at home I will post my configuration, how I can’t.

[font=“arial, verdana, tahoma, sans-serif”][size=“2”]When using xampp on Windows (as it seems to be the case here), you don’t need to specify a socket in the db connection.

I don’t think there is any kind of problem with routes since you don’t use them. In the case of a route error, you should see something like [color="#555555"][font=“Arial, Helvetica, sans-serif”][size=“2”]Unable to resolve the request “gii/model”.[/size][/font][/color])[/size][/font]

In my config file for Mac I have:


The problem here is that xamp/mamp/wamp uses a mysql server that is not the default of the sysrem, so you can have some problem.

Check if you have got the socket in


I am using xampp 1.7.0, i uninstalled and installed xampp 1.7.4, now i am able to generate model classes.

I am not sure what’s went wrong when i am using 1.7.0.

Thanks for every one who tried to help me on this.

You are welcome!

Good that you solved it.