Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 217
  • Last Modified:

URGENT: mysql_connect fails

I am trying to setup a local linux box as a development enviornment for my project. This is my first real crack at setting up a linux server. At this point I have all the major pieces on and working (apache, php, mysql, etc) but I am having trouble getting php to connect to mysql. I can get to mysql just fine from the command line or through gui toolsso it's up and running but when my php scripts try and connect I get the following error

Warning: mysql_connect(): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (13) in /var/sites/sitename/html/includes/database.php on line 558

I've been looking all over the web for solutions and tried almost everything but haven't had any luck. So here is what I have tried let me know what I need to do...

I tried changing the location of the mysql.sock file from /var/lib/mysql/mysql.sock to /tmp/mysql.sock through the /etc/my.cnf file then I went into the php.ini file and altered the default socket to point to /tmp/mysql.sock... and restart mysql and apache but the error continued....

I've checked permissions and those are fine.

I've tried passing the socket location '/tmp/mysql.sock' in through the mysql_connect function and still get the same error except the '/var/lib/mysql/mysql.sock' not says /tmp/mysql.sock

The version of of software are as follows...
OS = Fedora Core 4
php = 4.3.11-2.8
mysql = 4.1.16-1
apache = 2.0.54-10


any ideas? this is the last step to me being able to use this box....

0
Isisagate
Asked:
Isisagate
  • 2
  • 2
1 Solution
 
AmigoJackCommented:
you surely searched enough?

http://www.google.com/search?q=%22connect+to+local+MySQL+server+through+socket%22

a quick overview looks like you may forget a host, a user/pass or that you havent created a propriate user within mysql with enough grants.

maybe theres also a firewall blocking an essential mysql port?
0
 
IsisagateAuthor Commented:
the users are infact created with all priviledges, the port is not blocked, the apache web server and mysql reside on the same box "localhost" is the host being used.
0
 
AmigoJackCommented:
can you give us an excerpt of ALL your code until the error raises?
0
 
JB04Commented:
after the mysql_connect function call add some error checking, eg.


mysql_connect('localhost', 'user', 'pass') or die(mysql_error());





That will output the last error given, let us know what if anything that outputs




0
 
IsisagateAuthor Commented:
Alright here is what I know so far.... I disabled SELinux (security enhanced Linux) that's new to fedora and the connection doesn't bomb any more however no data is being written to the page. The page's none database content is being written to the page but where the data is supposed to be there is nothing. Suggestions on how to fix or diagnose what's up configuration wise? The code that is being executed works fine on my windows dev machine and my linux web hosting server but not here so something still seems flakey with the configurations.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now