1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

MySQL error

Discussion in 'PHP' started by Blagger, Apr 9, 2005.

  1. #1
    I keep getting this error, and was wondering if anyone knows how to fix it?

    mysql_pconnect(): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

    Thanks to anyone who can help.
     
    Blagger, Apr 9, 2005 IP
  2. anton-io!

    anton-io! Active Member

    Messages:
    540
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    58
    #2
    local or remote?

    You're obviously not connection properly to the database, check you database name, password and location

    try using mysql_connect()
     
    anton-io!, Apr 9, 2005 IP
  3. J.D.

    J.D. Peon

    Messages:
    1,198
    Likes Received:
    65
    Best Answers:
    0
    Trophy Points:
    0
    #3
    It may be that your server isn't listeing on the default port. Run this command and see if anything comes back:

    netstat -an | grep 3306

    If there's a server listening on this port (or whatever other port you chose for MySQL), it may be that your server is configured not to accept connections on the loopback address. Try connecting to your actual IP address using the mysql utility (replace values in brackets with actual values)

    mysql -u [my-user-name] -p -h [my-ip-address]

    and check your system databases:

    select host, db, user from db;
    select host, user from user;
    select host, db from host;

    See if localhost is listed in any of these results (it may also be a wildcard).

    J.D.
     
    J.D., Apr 9, 2005 IP
  4. TommyD

    TommyD Peon

    Messages:
    1,397
    Likes Received:
    76
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Sounds like the socket isn't open, I would check it's just running, first.

    tom
     
    TommyD, Apr 9, 2005 IP
  5. Blagger

    Blagger Peon

    Messages:
    259
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Thanks for all your response, appreciate it. It's local, by the way.

    J.D.
    I don't think I can run a command on a shared host, can I? I'm sure I sound dumb, I have no knowledge what so ever on MySQL.

    My next dumb question would be, which MySQL utility?

    I think I'm going to struggle here.

    Thanks
     
    Blagger, Apr 9, 2005 IP
  6. davedx

    davedx Peon

    Messages:
    429
    Likes Received:
    21
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Sounds like an issue your host should sort out, IMHO (unless you're trying to do something funky with your code). I'd open a ticket with them.
     
    davedx, Apr 9, 2005 IP
  7. J.D.

    J.D. Peon

    Messages:
    1,198
    Likes Received:
    65
    Best Answers:
    0
    Trophy Points:
    0
    #7
    There's a utility called mysql. You need access to the command line to be able to use this utility. If you run mysql as I quoted, you will connect as the specified user to the machine identified by the specified address. Try 127.0.0.1 and the actual IP address of your machine. If you can connect using one of these addresses, you can use the same address in your PHP code.

    J.D.
     
    J.D., Apr 9, 2005 IP
  8. fryman

    fryman Kiss my rep

    Messages:
    9,604
    Likes Received:
    777
    Best Answers:
    0
    Trophy Points:
    370
    #8
    I agree with davedx, this happened to me countless times on shared hosting. One trouble ticket and problem solved in a few minutes.
     
    fryman, Apr 9, 2005 IP
  9. J.D.

    J.D. Peon

    Messages:
    1,198
    Likes Received:
    65
    Best Answers:
    0
    Trophy Points:
    0
    #9
    What I would try first, though, is to try connecting using TCP/IP sockets. For example:

    mysql_connect("localhost", "root", "root");
    PHP:
    It seems that you used Unix sockets to connect (i.e. /tmp/mysql.sock). This file may be located elsewhere, depending on how your hosting company set your MySQL. If you want to use Unix sockets, you need to ask your hosting company where the socket file is located. If you have access to the command line, you can try runnin this command to figure it out (you may need to find where mysqld is located first):

    mysqld --help --verbose | grep "^socket"

    J.D.
     
    J.D., Apr 10, 2005 IP
  10. Blagger

    Blagger Peon

    Messages:
    259
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #10
    Thanks guys, I appreciate you all taking the time to respond.

    I have opened a trouble ticket with my web host, as I don't have access to make changes because I'm on a shared host.

    I think you are right J.D. I have read that some hosts have MySQL set up in different locations.

    Thanks for your feedback, I now have more understanding on this issue.
     
    Blagger, Apr 10, 2005 IP
  11. Blagger

    Blagger Peon

    Messages:
    259
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #11
    My host has sorted it, thanks for all your help.
     
    Blagger, Apr 10, 2005 IP
  12. J.D.

    J.D. Peon

    Messages:
    1,198
    Likes Received:
    65
    Best Answers:
    0
    Trophy Points:
    0
    #12
    Do you mind sharing what was the problem?
     
    J.D., Apr 10, 2005 IP
  13. TommyD

    TommyD Peon

    Messages:
    1,397
    Likes Received:
    76
    Best Answers:
    0
    Trophy Points:
    0
    #13
    Good to hear!

    I'm with J.D. please share your experience.

    tom
     
    TommyD, Apr 10, 2005 IP
  14. Blagger

    Blagger Peon

    Messages:
    259
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #14
    Sorry for the slow reply.

    It may seem like a stupid mistake but the mysql host in the common.php file should have been mysql.websitesoure.net NOT localhost.

    According to the particular read me file this wasn't something that was normally to be altered. I suppose I should have checked this, especially as I'm on a shared host.

    Thanks for your help.
     
    Blagger, Apr 10, 2005 IP
  15. fryman

    fryman Kiss my rep

    Messages:
    9,604
    Likes Received:
    777
    Best Answers:
    0
    Trophy Points:
    370
    #15
    The good thing about share hosting is that you can open a ticket and have someone work it out for you.

    Get a dedicated server and you are on your own... I had to hire a server admin to keep an eye on the server and fix any potential problems.
     
    fryman, Apr 10, 2005 IP
  16. rvarcher

    rvarcher Peon

    Messages:
    69
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #16
    I ran across this same problem with a recent webhosting account I got with GoDaddy.com. The MySQL database was located on a different server than the shared web server so localhost wouldn't work in the connection string. You had to specify the name of the server that had the database. The host name of the database server should be displayed in the MySQL settings in whichever particular server/web hosting/database management utility your hosting company uses.
     
    rvarcher, Apr 11, 2005 IP
  17. sheelgohe

    sheelgohe Peon

    Messages:
    380
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #17
    Check your ip settings....
    just do this---Go to command prompt and write config/renew
     
    sheelgohe, Apr 12, 2005 IP