Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8923787
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T07:13:40+00:00 2026-06-15T07:13:40+00:00

I try to connect to a distant host like this: class Singleton { public

  • 0

I try to connect to a distant host like this:

    class Singleton {
  public static $connection;

  public static function getConnection(){
      if(self::$connection==null){
         $dsn = 'mysql:dbname=gtrscrpt_ubot;';
         $user = 'MyUser';
         $password = 'MyPassword';
        try {
           self::$connection = new PDO('mysql:host=gator188.hostgator.com;port=2983;dbname=gtrscpt_ubot;',$user,$password );
           self::$connection->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
        } catch (PDOException $e) {
            echo 'Connection failed: ' . $e->getMessage();
        }
      }
      return self::$connection;
  }

}


Singleton::getConnection();

I get this:

Connection failed: SQLSTATE[HY000] [2006] MySQL server has gone away

The problem is that I dont know if my code is wrong or cant I really connect to the server (I know however that I should connect)

UPDATE:
Connection failed: SQLSTATE[HY000] [2000] mysqlnd cannot connect to MySQL 4.1+ using the old insecure authentication. Please use an administration tool to reset your password with the command SET PASSWORD = PASSWORD(‘your_existing_password’). This will store a new, and more secure, hash value in mysql.user. If this user is used in other scripts executed by PHP 5.2 or earlier you might need to remove the old-passwords flag from your my.cnf file**

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T07:13:41+00:00Added an answer on June 15, 2026 at 7:13 am

    Looks like a problem with your host. Verify with them that your hostname, port and credentials are correct, and that your server can access external outgoing networking.

    From the MySQL docs:

    C.5.2.9. MySQL server has gone away

    The most common reason for the MySQL server has gone away error is that the server timed out and closed the connection.

    Edit:

    Your host is still using the old MySQL password scheme. If you have access to MySQL you can update your password as the error suggested:

    SET PASSWORD FOR 'User'@'Host'=PASSWORD('yourpassword');
    FLUSH Privileges
    

    Replace User and Host with your details. More info in this question.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I try to connect to my BD This is my code public class JavaSQLTest
try to set host in dsn of pdo like this: <?php /* Connect to
I try to connect to a server with a self-signed certificate. I use this
I'm modifying Python code that have this form: def foo(self): try: connect socket except
I try to connect to the database with this code: try { Class.forName(org.apache.derby.jdbc.ClientDriver); String
When I try to connect Weblogic t3s protocol in Solaris Server, it shows this
I try to connect to CVS through eclipse. After entering (host, repository path, user,
my code is this try { //Connect to the login server socket = new
I try to connect to Facebook throught Facebook API, I follow this example: https://github.com/facebook/facebook-android-sdk/tree/master/examples/simple
When I try to connect with the Redis server with this code I haven't

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.