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.

Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY000] [2002]

Discussion in 'MySQL' started by webgames247, Jul 7, 2016.

  1. #1
    Hi,

    Sorry if i posted in a wrong section. My site keep getting few times a day about [2002] errors and usually last 3-10 minutes and the site is back up and working normal again.

    here are the error.

    Here is what i have in db-config.php
    
    <?php
    if(count(get_included_files())==1) header("Location: http://www.xxxxx.com");
    // DISPLAY ERROR SETTING FOR SITE
    
    error_reporting(E_ALL);
    error_reporting(E_ALL && ~E_NOTICE);
    
    $user="xxxxxxx";
    $pass="xxxxx";
    
    $dbh = new PDO('mysql:host=localhost;dbname=xxxxxxx', $user, $pass);
    ?>
    
    PHP:

    SEMrush
     
    webgames247, Jul 7, 2016 IP
    SEMrush
  2. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,626
    Likes Received:
    719
    Best Answers:
    151
    Trophy Points:
    420
    #2
    You're a bit off base posting wise, but not too bad.

    That error is usually because of a socket-error - is this on a production server, or on a test/development server? What type of server is it on? (Windows, Linux, what type of Linux, OSX?).

    There are plenty of information about this on Google, here is a couple of links:
    https://www.drupal.org/node/2110549
    http://stackoverflow.com/questions/...-sqlstatehy000-2002-no-such-file-or-directory

    The information in the first link is based on Drupal, but can be used for other setups as well
     
    PoPSiCLe, Jul 7, 2016 IP
  3. webgames247

    webgames247 Active Member

    Messages:
    411
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    78
    #3
    Thanks for replied,

    Site is currently live and I don't know anything about coding any help are very appreciate

    Site is currently using 1and1 dedicated server XL 12i Managed by 1and1. Here are server detail:
    Current use:
    - MySQL5.5
    - php 5.4

    When error occur. I try to connect to phpmyamdin i got the following message
     
    Last edited: Jul 8, 2016
    webgames247, Jul 8, 2016 IP
  4. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,626
    Likes Received:
    719
    Best Answers:
    151
    Trophy Points:
    420
    #4
    So? If the server is managed by 1and1, tell them about the problem, and have them fix it. It has to do with the server not being connectable, or timing out, or something else. Look at the server-logs, it should say something about why this happens, if it normally works fine. It might have to do with server load, queries stressing the database, bad config of either the server as a whole, SQL, the code you're running on the server, etc. etc. There are hundreds of possible reasons for this to happen, and it's impossible to pinpoint exactly what is happening based on what you're telling us.

    The error message is quite clear, and is telling you exactly what is happening, however it doesn't tell you WHY it's happening.
     
    PoPSiCLe, Jul 8, 2016 IP