首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >hostgator - PHP无法连接

hostgator - PHP无法连接
EN

Stack Overflow用户
提问于 2013-11-11 11:05:40
回答 1查看 1.1K关注 0票数 0

我在非逗号的情况下遇到了逗号问题。当我试图连接到HOSTGATOR服务器中托管的mysql服务器时,我得到了以下错误:

代码语言:javascript
复制
Could not connect to database. 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.

在这里的解决方案非常简单和简单:http://www.phpro.org/articles/Database-Connection-Failed-Mysqlnd-Cannot-Connect-To-MySQL.html

但是...HostGator不想更改"my.cnf“文件!由于我的特权,本教程中的大多数查询都被拒绝了。

还有别的解决办法吗?我错过了?谢谢!

EN

回答 1

Stack Overflow用户

发布于 2013-11-11 18:19:50

见Hostgator help

下面的代码使用PDO进行连接。

代码语言:javascript
复制
$DBH = new PDO("mysql:host=$host;dbname=$database", $username, $password);  
  $DBH->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );  
  //SELECT,INSERT queries here

}  
catch(PDOException $e) {  
    echo "I'm sorry I'm afraid you can't do that.". $e->getMessage() ;// Remove or modify after testing 
    file_put_contents('PDOErrors.txt',date('[Y-m-d H:i:s]'). $e->getMessage()."\r\n", FILE_APPEND);  
}  
// close the connection
$DBH = null;
?>
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/19904772

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档