Yii Framework Forum: Mysql Connection Error - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Mysql Connection Error Rate Topic: -----

#1 User is offline   jhouse153 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 20
  • Joined: 10-January 13
  • Location:Salt Lake City, UT

Posted 10 January 2013 - 10:47 AM

I'm using Yii for the first time so please excuse the novice question I'm about to ask.

I'm following the steps in setting up my Yii application, and have encountered the following error in connecting to the database:

CDbConnection failed to open the DB connection: SQLSTATE[HY000] [2003] Can't connect to MySQL server on '192.168.0.1' (13)

Here are the parameters I've set up for the db array:

'db'=>array(
	'connectionString' => 'mysql:host=192.168.0.1;port=3306;dbname=Sandbox;',
	'emulatePrepare' => true,
	'username' => 'username',
	'password' => 'password',
	'charset' => 'utf8',
),


I have changed the array on main.php and console.php. I've tried it with/without the "unix_socket" parameter as well with no luck.

I'm lost on what to try next. Any help is appreciated.
0

#2 User is offline   Da:Sourcerer 

  • Elite Member
  • PipPipPipPipPip
  • Yii
  • Group: Members
  • Posts: 1,222
  • Joined: 30-March 11
  • Location:Berlin, Germany

Posted 10 January 2013 - 10:52 AM

That's not really a novice question. Yii/PHP seems to be unable to connect to your MySQL server. Check if that IP is really correct. Also, see here.
programmer /ˈprəʊgramə/, noun: a device that converts ►coffee into ►code
0

#3 User is offline   jhouse153 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 20
  • Joined: 10-January 13
  • Location:Salt Lake City, UT

Posted 10 January 2013 - 10:59 AM

Thanks for the response. I'll review your link. I'm positive thats the IP address (I have other applications connecting to it)
0

#4 User is offline   developer! 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 110
  • Joined: 28-November 12

Posted 10 January 2013 - 01:06 PM

if ip is correct. try to make sure your dbname, username and password are correct as well. are you using any configurations files in your config folder other than main.php(may be unknowingly you are overwriting the db array in main.php)??

Thanks
0

#5 User is offline   developer! 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 110
  • Joined: 28-November 12

Posted 10 January 2013 - 01:09 PM

larryullman's Introduction to the Yii Framework this is really useful for beginners
0

#6 User is offline   Da:Sourcerer 

  • Elite Member
  • PipPipPipPipPip
  • Yii
  • Group: Members
  • Posts: 1,222
  • Joined: 30-March 11
  • Location:Berlin, Germany

Posted 10 January 2013 - 04:20 PM

View Postdeveloper!, on 10 January 2013 - 01:06 PM, said:

try to make sure your dbname, username and password are correct as well.

That would result into error messages very different from what has been posted here. Something must be hampering connectivity at a lower level.
programmer /ˈprəʊgramə/, noun: a device that converts ►coffee into ►code
0

#7 User is offline   Coksnuss 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 142
  • Joined: 14-May 09

Posted 11 January 2013 - 10:08 AM

Have you tried to setup a local database and connect to 127.0.0.1 or localhost to make sure that it isn't a PDO problem?

Also it would be useful if you have a local MySQL client and could tell us if
mysql -h 192.168.0.1 -u root -p
is working.

Are you sure that 192.168.0.1 is correct and you did not meant 127.0.0.1? (I guess the first IP address is from your router)
0

#8 User is offline   mayelamingi 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 7
  • Joined: 16-August 13

Posted 16 August 2013 - 02:07 PM

I too have this exact same problem.
I can connect using the Yii framework to my localhost mysql database using xampp
I can connect to my mysql database (on a linux server on Godaddy), using normal php connectionstring.
But when I use the connectionstring in the Yii Framework and do the recommended tests, it doesn't work inside the framework.

This works:
'db'=>array(
'connectionString' => 'mysql:host=127.0.0.1;port=3306,dbname=cmi',
'emulatePrepare' => true,
'username' => 'root',
'password' => '',
'charset' => 'utf8',
),

This connectionstring works in my normal (no framework) way.
$con = mysql_connect("10.6.186.140", "smucmap", "XXXXXX") or die("Could not Connect to MySQL server!");

This does not work:
'db'=>array(
'connectionString' => 'mysql:host=10.6.186.140;port=3306,dbname=smucmap',
'emulatePrepare' => true,
'username' => 'smucmap',
'password' => 'XXXXX',
'charset' => 'utf8',
),

Does anything else need to be changed when switching from a local database to using one out in the cloud?
0

#9 User is offline   valeantudor 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 1
  • Joined: 18-August 13

Posted 18 August 2013 - 08:55 AM

View Postmayelamingi, on 16 August 2013 - 02:07 PM, said:

I too have this exact same problem.
I can connect using the Yii framework to my localhost mysql database using xampp
I can connect to my mysql database (on a linux server on Godaddy), using normal php connectionstring.
But when I use the connectionstring in the Yii Framework and do the recommended tests, it doesn't work inside the framework.

This works:
'db'=>array(
'connectionString' => 'mysql:host=127.0.0.1;port=3306,dbname=cmi',
'emulatePrepare' => true,
'username' => 'root',
'password' => '',
'charset' => 'utf8',
),

This connectionstring works in my normal (no framework) way.
$con = mysql_connect("10.6.186.140", "smucmap", "XXXXXX") or die("Could not Connect to MySQL server!");

This does not work:
'db'=>array(
'connectionString' => 'mysql:host=10.6.186.140;port=3306,dbname=smucmap',
'emulatePrepare' => true,
'username' => 'smucmap',
'password' => 'XXXXX',
'charset' => 'utf8',
),

Does anything else need to be changed when switching from a local database to using one out in the cloud?

Have you tried with 'connectionString' => 'mysql:host=localhost,dbname=smucmap' ?
0

#10 User is offline   ndnguyen 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 1
  • Joined: 01-January 14

Posted 01 January 2014 - 04:53 AM

View Postmayelamingi, on 16 August 2013 - 02:07 PM, said:

I too have this exact same problem.
I can connect using the Yii framework to my localhost mysql database using xampp
I can connect to my mysql database (on a linux server on Godaddy), using normal php connectionstring.
But when I use the connectionstring in the Yii Framework and do the recommended tests, it doesn't work inside the framework.

This works:
'db'=>array(
'connectionString' => 'mysql:host=127.0.0.1;port=3306,dbname=cmi',
'emulatePrepare' => true,
'username' => 'root',
'password' => '',
'charset' => 'utf8',
),

This connectionstring works in my normal (no framework) way.
$con = mysql_connect("10.6.186.140", "smucmap", "XXXXXX") or die("Could not Connect to MySQL server!");

This does not work:
'db'=>array(
'connectionString' => 'mysql:host=10.6.186.140;port=3306,dbname=smucmap',
'emulatePrepare' => true,
'username' => 'smucmap',
'password' => 'XXXXX',
'charset' => 'utf8',
),

Does anything else need to be changed when switching from a local database to using one out in the cloud?


This works for me: ( also use godaddy host)

'db'=>array(
'connectionString' => 'mysql:host=50.62.209.46; port=3306;dbname=soccer_tips',
'emulatePrepare' => true,
'username' => 'soccer',
'password' => '*****',
'charset' => 'utf8',
),
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users