Unable to connect to mysql

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Ratzzak
Forum Newbie
Posts: 21
Joined: Sat Jun 13, 2009 10:56 am

Unable to connect to mysql

Post by Ratzzak »

I'm trying to connect to mysql from php.
But i'm unable to connect.
I'm getting all these errors instead..

Warning: mysql_connect(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Asia/Calcutta' for '5.5/no DST' instead in F:\Program Files\Apache2.2\htdocs\index.php on line 8 Warning: mysql_connect(): [2002] A connection attempt failed because the connected party did not (trying to connect via tcp://localhost:3306) in F:\Program Files\Apache2.2\htdocs\index.php on line 8 Warning: mysql_connect(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Asia/Calcutta' for '5.5/no DST' instead in F:\Program Files\Apache2.2\htdocs\index.php on line 8 Warning: mysql_connect(): A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. in F:\Program Files\Apache2.2\htdocs\index.php on line 8 Warning: main(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Asia/Calcutta' for '5.5/no DST' instead in F:\Program Files\Apache2.2\htdocs\index.php on line 8 Fatal error: Maximum execution time of 30 seconds exceeded in F:\Program Files\Apache2.2\htdocs\index.php on line 8


Apache and PHP are working fine.
Problem occurs only when i try to connect to mysql.
I have enabled the mysql extension in php.ini file

Thanx
Ratzzak
Ratzzak
Forum Newbie
Posts: 21
Joined: Sat Jun 13, 2009 10:56 am

Re: Unable to connect to mysql

Post by Ratzzak »

I have been using wamp till date and now have done separate installations..
Stuck badly.. need some help..
User avatar
Jade
Forum Regular
Posts: 908
Joined: Sun Dec 29, 2002 5:40 pm
Location: VA

Re: Unable to connect to mysql

Post by Jade »

You need to do this before you connect to your database: http://php.net/manual/en/function.date- ... ne-set.php
Ratzzak
Forum Newbie
Posts: 21
Joined: Sat Jun 13, 2009 10:56 am

Re: Unable to connect to mysql

Post by Ratzzak »

I still get this error

Warning: mysql_connect(): [2002] A connection attempt failed because the connected party did not (trying to connect via tcp://localhost:3306) in F:\Program Files\Apache2.2\htdocs\index.php on line 8 Warning: mysql_connect(): A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. in F:\Program Files\Apache2.2\htdocs\index.php on line 8 Fatal error: Maximum execution time of 30 seconds exceeded in F:\Program Files\Apache2.2\htdocs\index.php on line 8
User avatar
Jade
Forum Regular
Posts: 908
Joined: Sun Dec 29, 2002 5:40 pm
Location: VA

Re: Unable to connect to mysql

Post by Jade »

It sounds like MySQL isn't running on that machine. Are you sure it's turned on?
Ratzzak
Forum Newbie
Posts: 21
Joined: Sat Jun 13, 2009 10:56 am

Re: Unable to connect to mysql

Post by Ratzzak »

I'm able to access it via command prompt and also db-visualizer is working fine.
User avatar
Jade
Forum Regular
Posts: 908
Joined: Sun Dec 29, 2002 5:40 pm
Location: VA

Re: Unable to connect to mysql

Post by Jade »

Do you have permissions to use the socket? What happens if you open a browser and type in http://localhost ?
Post Reply