PDO连接有什么问题? [英] Whats wrong with PDO connection?

查看:55
本文介绍了PDO连接有什么问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能的

我正在使用PDO连接数据库.

I am connecting the DB using the PDO.

      $DBH = new PDO('mysql:host=localhost;dbname=name','dbusername','dbpassword'); 

这在这里不起作用.

我遇到了错误

SQLSTATE[HY000] [2002] Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)

但是无论我们在mysql_connect中已经完成的连接都可以正常工作.请您帮我这个忙.

But whatever the connection we already done in mysql_connect thats working fine.Could you please help me on this.

推荐答案

某些Web托管提供商将自定义域名或IP地址用于MySQL连接,我建议您首先检查有关数据库连接的托管手册.
通常,通过控制面板创建MySQL数据库,您会收到数据库连接属性的示例.

Some web hosting providers use custom domain names or IP addresses for MySQL connection, I would advise you first of all to check hosting manual on database connections.
Usually by creating MySQL database through control panel, you would receive example of database connection properties.

这篇关于PDO连接有什么问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆