URGENT: mysql_connect fails

Posted on 2006-04-09
Last Modified: 2012-05-05
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....

Question by:Isisagate
    LVL 12

    Accepted Solution

    you surely searched enough?

    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?
    LVL 11

    Author Comment

    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.
    LVL 12

    Expert Comment

    can you give us an excerpt of ALL your code until the error raises?
    LVL 7

    Expert Comment

    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

    LVL 11

    Author Comment

    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.

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Join & Write a Comment

    This article will explain how to display the first page of your Microsoft Word documents (e.g. .doc, .docx, etc...) as images in a web page programatically. I have scoured the web on a way to do this unsuccessfully. The goal is to produce something …
    Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
    The viewer will learn how to count occurrences of each item in an array.
    This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

    732 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now