在服务器上连接PDO时出错


error occurs while connecting PDO on server

这是我的代码,它在本地主机中工作,但在服务器中不工作

     $dbtype = 'mysql';                 // Normally mysql
     $host = 'localhost';                   // This is normally set to localhost
     $db_username = 'name';                         // DB username
     $db_password = 'pass';                     // DB password
     $db_name = 'db_name';                          // DB database name
     $dbprefix = 'db_';                 // Do not change unless you need to!
     $cat_table="db_cat";   
    try
    {
        $pdo = new PDO('mysql:host='. $host .';port=2082;dbname='.$db_name, $db_username, $db_password);
     }
    catch (PDOException $e)
    {
        die($e);
    }
    ?>

错误消息

exception 'PDOException' with message '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' in /home/jeywigki/public_html/hotel/db/config.php:13 Stack trace: 
#0 /home/jeywigki/public_html/hotel/db/config.php(13): PDO-
>__construct('mysql:host=loca...', 'table', 'pass') #1 /home/jeywigki/public_html/hotel/index.php(3): require_once('/home/jeywigki/...') #2 {main}

请帮帮我。提前感谢

我不确定,但这可能是问题所在。

您可以尝试以下操作:引号中的mysql:host=$host;dbname=$db_name

  try
    {
        $pdo = new PDO("mysql:host=$host;dbname=$db_name", $db_username, $db_password);
    }
    catch (PDOException $e)
    {
        exit('Error Connecting To DataBase');
    }

文档