[英]error occurs while connecting PDO on server
this is my code it's working in local host but not in 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);
}
?>
ERROR MESSAGE 错误信息
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}
kindly help me. 请帮助我。 thanks in advance
提前致谢
I am not sure but it could be the issue. 我不确定,但这可能是问题所在。
you can try this: mysql:host=$host;dbname=$db_name
inside in quotes. 您可以尝试这样做:
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');
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.