Jump to content



Photo
- - - - -

Can't connect to local MySQL server through socket


This topic has been archived. This means that you cannot reply to this topic.
13 replies to this topic

#1   lorr2000

lorr2000
  • Members
  • 2 posts

Posted 28 April 2004 - 10:34

I am really at a dead end here. I can't figure out what is wrong. This the error i am getting

Warning: mysql_connect(): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) in /usr/local/apache2/htdocs/includes/functions/database.php on line 19
Unable to connect to database server!

I don't know why this is. I have the setting in etc/my.conf to point to /var/lib/mysql/mysql.sock . I can create databases and all that no problem. I don't know why it is looking in /tmp/mysql.sock.

Is it in the code anywhere that it specifies to look there.
I need help please!!!
/sad.gif' class='bbc_emoticon' alt=':(' />

#2   AlanR

AlanR
  • Members
  • 3,711 posts

Posted 28 April 2004 - 14:36

You need to post the catalog/includes/configure.php file.

Check this line first:

define('DIR_FS_CATALOG', '/the/server/path/to/my/catalog/');

Obvously it does not look exactly like that. /biggrin.gif' class='bbc_emoticon' alt=':D' />
Local: Mac OS X 10.5.8 - Apache 2.2/php 5.3.0/MySQL 5.4.10 • Web Servers: Linux
Tools: BBEdit, Coda, Versions (Subversion), Sequel Pro (db management)

#3   unixfox

unixfox
  • Members
  • 33 posts

Posted 28 April 2004 - 15:02

I'm getting a similar error. and all I did was enable the PhPAdmin !!

This is my error:

Warning: mysql_connect(): Access denied for user: 'rolltexi_oscom@localhost' (Using password: YES) in /home/rolltexi/wwwroot/rolltexinc.com/osc/catalog/includes/functions/database.php on line 19
Unable to connect to database server!

#4   unixfox

unixfox
  • Members
  • 33 posts

Posted 28 April 2004 - 15:31

I found this at the MYSQL web site. Maybe it will help.

[2.3] The error message "Warning: MySQL Connection Failed: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (111)..." is displayed. What can I do?

For RedHat users, Harald Legner suggests this on the mailing list:

On my RedHat-Box the socket of mysql is /var/lib/mysql/mysql.sock. In your php.ini you will find a line
mysql.default_socket = /tmp/mysql.sock
change it to
mysql.default_socket = /var/lib/mysql/mysql.sock
Then restart apache and it will work.

Here is a fix suggested by Brad Ummer in the phpwizard forum:

First, you need to determine what socket is being used by MySQL.
To do this, telnet to your server and go to the MySQL bin directory. In this directory there should be a file named mysqladmin. Type ./mysqladmin variables, and this should give you a bunch of info about your MySQL server, including the socket (/tmp/mysql.sock, for example).
Then, you need to tell PHP to use this socket.
Assuming you are using PHP 3.0.10 or better, you can specify the socket to use when you open the connection. To do this in phpMyAdmin, you need to complete the socket information in the config.inc.php3.
For example: $cfg['Servers'][$i]['socket'] = '/tmp/mysql.sock';
Have also a look at the corresponding section of the MySQL documentation.

#5   arrimat

arrimat
  • Members
  • 33 posts

Posted 28 July 2006 - 06:55

You need to post the catalog/includes/configure.php file.

Check this line first:

define('DIR_FS_CATALOG', '/the/server/path/to/my/catalog/');

Obvously it does not look exactly like that. /biggrin.gif' class='bbc_emoticon' alt=':D' />



I'm having the same pb and I can't figure it out...
How can I find out what my path is for 'DIR_FS_CATALOG'??

My error is the following:
Warning: mysql_connect(): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) in /data/11/0/133/7/948333/user/977971/htdocs/catalog/includes/functions/database.php on line 20
Unable to connect to database server!

is it "/data/11/0/133/7/948333/user/977971/htdocs/catalog/"??

Please let me know...

Mat

#6   Kids Juke Box

Kids Juke Box
  • Members
  • 8 posts

Posted 04 April 2008 - 23:34

Dont know if this has been solved elsewhere, but I've received this error several times during some of our installation. Every time the problem has been in the configure.php files with this line:

define('DB_SERVER', 'localhost');

Almost every host has a different setup, but this might solve the problem for you. You should be able to log into phpmyadmin or call tech support with your host, and they can provide you the server details.

Ex. Here are a few examples of what it could look like...

define('DB_SERVER', 'mysql123.myhost.com');

or GoDaddy, they use IP Address:

define('DB_SERVER', '10.1.10.1');

****

Also, to find the path to your catalog you can use the phpinfo(); command. Create a file in Notepad and add the following:

<?php
phpinfo();
?>

Then save to a file called phpinfo.php (make sure that you do save it as .php instead of .txt) upload it to your server via ftp or your servers file manager. Then in your browser navigate to the file. ex. mydomain.com/phpinfo.php

Scroll down and look for APACHE ENVIRONMENT, and the line DOCUMENT ROOT

Hope this helps!

Shean Hoxie
Webmaster- Kids Juke Box

Edited by Jan Zonjee, 13 August 2008 - 21:16.

----------------------------------
Shean Hoxie
Webmaster- Kids Juke Box
----------------------------------

#7   elnino3

elnino3
  • Members
  • 14 posts

Posted 13 August 2008 - 21:12

or in my case 127.0.0.1

#8   mousemedia

mousemedia
  • Members
  • 7 posts

Posted 10 December 2009 - 04:22

Im having the same problem. My admin is not working, i get the

Warning: mysql_connect() [function.mysql-connect]: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) in /home/content/x/y/z/xyzhostname/html/admin/includes/functions/database.php on line 19
Unable to connect to database server!

The main site works fine. I triple checked the admin/includes/configure.php settings and everything is perfect. I'm at a loss as I know my settings are correct, I've set up at least 6 osCommerce/CreLoaded sites. When I get this error, I first check the configure.php settings, fix, then I'm done.

But this time, I'm stumped. The regular site works a charm, the admin is giving me a headache. Please help!

#9   HOSTDR

HOSTDR
  • Members
  • 1 posts

Posted 23 December 2009 - 06:10

I have the same issue only with admin, I migrated a client to another server and it started happening.


Im having the same problem. My admin is not working, i get the

Warning: mysql_connect() [function.mysql-connect]: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) in /home/content/x/y/z/xyzhostname/html/admin/includes/functions/database.php on line 19
Unable to connect to database server!

The main site works fine. I triple checked the admin/includes/configure.php settings and everything is perfect. I'm at a loss as I know my settings are correct, I've set up at least 6 osCommerce/CreLoaded sites. When I get this error, I first check the configure.php settings, fix, then I'm done.

But this time, I'm stumped. The regular site works a charm, the admin is giving me a headache. Please help!



#10   ginaq79

ginaq79
  • Members
  • 1 posts

Posted 16 September 2010 - 05:52

Help!!! total newbie to the site and to using these programs... this is the error code i'm getting:

Warning: mysql_connect() [function.mysql-connect]: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) in /home/content/33/6718933/html/includes/functions/database.php on line 19
Unable to connect to database server!

I"m hoping to find out what i can do to fix it before i attempt to redo the whole thing! =(

#11   cantex123

cantex123
  • Members
  • 3 posts

Posted 03 January 2011 - 19:43

Hello everyone,

I am also getting same error,
It's my new store, i just upload my all data and database in to the server.

I check my all file in "/includes/configure.php" and "admin/includes/configure.php but still getting same error

Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'xxx_osc'@'localhost' (using password: YES) in /home/xxx/public_html/includes/functions/database.php on line 20
Unable to connect to database server!

Please any one can help.

Thank you in advance.

#12   DDhodg

DDhodg
  • Members
  • 5 posts

Posted 01 June 2011 - 19:38

Please can someone help me fix the error I have like the above...


Warning: mysql_connect() [function.mysql-connect]: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) in /www/sites/6b5/4c4/web/catalog/includes/functions/database.php on line 19
Unable to connect to database server!

Line 19 in database.php is below

if (USE_PCONNECT == 'true') {
$$link = mysql_pconnect($server, $username, $password);
} else {
$$link = mysql_connect ($server, $username, $password);
}

I really don't know what is wrong and I have also reloaded configure.php with no joy. Please help.

#13   DunWeb

DunWeb

    The Censored One

  • Members
  • 13,084 posts

Posted 01 June 2011 - 19:56

Dan,


Typically that error message has nothing to do with the database.php file. It is normally a user name / password mismatch for the database. Confirm the database name, User name and Database Password are correct.





Chris
:|: Was this post helpful ? Click the LIKE THIS button :|:

See my Profile to learn more about add ons, templates, support plans and custom coding (click here)

#14   DDhodg

DDhodg
  • Members
  • 5 posts

Posted 06 June 2011 - 09:22

Dan,


Typically that error message has nothing to do with the database.php file. It is normally a user name / password mismatch for the database. Confirm the database name, User name and Database Password are correct.





Chris



Hi Chris, yes stupidly i change mysql database password, I have changed it back but i'm still getting the same message. what do you suggest?

Thanks
Dan