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

‘db’=>array(

		'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,

Pavan

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?


<WEBROOT>

    --artist

        --protected

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(

......


'modules'=&gt;array(


    'gii'=&gt;array(


        'class'=&gt;'system.gii.GiiModule',


        '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(

'basePath'=&gt;dirname(__FILE__).DIRECTORY_SEPARATOR.'..',


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





// preloading 'log' component


'preload'=&gt;array('log'),





// autoloading model and component classes


'import'=&gt;array(


	'application.models.*',


	'application.components.*',


),





'modules'=&gt;array(


	// uncomment the following to enable the Gii tool


	


	'gii'=&gt;array(


		'class'=&gt;'system.gii.GiiModule',


		'password'=&gt;'pavan1',


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


		//'ipFilters'=&gt;array('127.0.0.1','::1'),


	),


	


),





// application components


'components'=&gt;array(


	'user'=&gt;array(


		// enable cookie-based authentication


		'allowAutoLogin'=&gt;true,


	),


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


	/*


	'urlManager'=&gt;array(


		'urlFormat'=&gt;'path',


		'rules'=&gt;array(


			'&lt;controller:&#092;w+&gt;/&lt;id:&#092;d+&gt;'=&gt;'&lt;controller&gt;/view',


			'&lt;controller:&#092;w+&gt;/&lt;action:&#092;w+&gt;/&lt;id:&#092;d+&gt;'=&gt;'&lt;controller&gt;/&lt;action&gt;',


			'&lt;controller:&#092;w+&gt;/&lt;action:&#092;w+&gt;'=&gt;'&lt;controller&gt;/&lt;action&gt;',


		),


	),


	*/


	/*


	'db'=&gt;array(


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


	),


	*/


	// uncomment the following to use a MySQL database


	


	'db'=&gt;array(


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


		'emulatePrepare' =&gt; true,


		'username' =&gt; 'root',


		'password' =&gt; '',


		'charset' =&gt; 'utf8',


	),


	


	'errorHandler'=&gt;array(


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


        'errorAction'=&gt;'site/error',


    ),


	'log'=&gt;array(


		'class'=&gt;'CLogRouter',


		'routes'=&gt;array(


			array(


				'class'=&gt;'CFileLogRoute',


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


			),


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


			/*


			array(


				'class'=&gt;'CWebLogRoute',


			),


			*/


		),


	),


),





// application-level parameters that can be accessed


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


'params'=&gt;array(


	// this is used in contact page


	'adminEmail'=&gt;'webmaster@example.com',


),

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.

‘db’=>array(

‘connectionString’=>‘mysql:host=localhost;dbname=yiidb;unix_socket=/home/michael/lamp/mysql/tmp/mysql.sock’,

‘username’=>‘root’,

‘password’=>‘pw’,

‘charset’=>‘utf8’

)

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


http://localhost/artist_new/index.php?r=gii/model

and not


http://localhost/artist/index.php?r=gii/model

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

1.artist

2.artist_new

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:


	'connectionString'=>'mysql:host=localhost;dbname=mambo;unix_socket=/Applications/MAMP/tmp/mysql/mysql.sock;',



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


D:\xampp\tmp\mysql\mysql.sock

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.