Latest LQ Deal: Linux Power User Bundle
Go Back > Forums > Linux Forums > Linux - Software
User Name
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.


  Search this Thread
Old 11-23-2003, 08:28 PM   #1
Registered: Oct 2003
Location: Canada
Distribution: Slackware
Posts: 340

Rep: Reputation: 30
Accessing MySQL from a PHP script (locally)

I just installed MySQL, Apache and PHP the way they installed it from "PHP - Fast and Easy Web Development" (kind of, RPM's didnt seem to work, so installing from source is what worked), i.e., For them to all work with each other (mostly just PHP needed additional parameters for configuration). MySQL works on its own, and I can access and parse my normal PHP scripts through Apache, but I used this code to try and access my MySQL database and it gave the error below:

PHP Code:
mysql_connect("localhost""root""mypassword") or die(mysql_error());

if (
$connection) {
$msg "it worked";


<title>MySQL Connection</title>

<? echo "$msg"?>

I get the following error message, and I'm not too sure what to make of it: Warning: mysql_connect(): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) in /usr/local/apache_1.3.29/htdocs/phpsql.php on line 2
Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

Hopefully some people have gone through this before and can help me out a little here, it would be much appreciated, I'm sitting here scratching my head...

Thanks alot!

Last edited by lowpro2k3; 11-23-2003 at 08:29 PM.
Old 11-23-2003, 08:47 PM   #2
Registered: Apr 2002
Posts: 549

Rep: Reputation: 30
either one or more of the following...

1. MySQL daemon isn't running.
2. it's working but configured to listen on a non-default port
3. Password is wrong (did u initialise the database using mysql_install_db)?
Old 11-23-2003, 09:50 PM   #3
Registered: Oct 2003
Location: Montreal Qc, Canada
Posts: 105

Rep: Reputation: 15
have you setup the file accordingly??


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP Shell Script (with MySql) Tony Empire Programming 1 09-20-2005 09:59 AM
issues with mirc script accessing our php script dtra Linux - Software 2 07-02-2005 04:30 PM
MySQL Returning very strange Values in PHP Script benrose111488 Programming 2 10-21-2004 11:26 AM
Running a php script locally on SuSE 9.1 Personal ClarkNG Linux - Newbie 5 08-20-2004 02:55 PM
accessing mysql from apache/php vher Linux - General 4 01-21-2003 08:06 AM > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 09:45 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration