我在使用PDO连接到Godaddy上的数据库时遇到问题 [英] I have a problem connecting to my db on godaddy with PDO

查看:72
本文介绍了我在使用PDO连接到Godaddy上的数据库时遇到问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试使用Godaddy上的pdo连接到我的数据库,但没有成功.

I have been trying to connect to my database using pdo on godaddy with no successs.

最初我得到了错误:

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

然后,我环顾四周,发现我需要将零件更改为插座.我寻找我的套接字找到它,并使用unix_socket=/tmp/mysql-1.sock对其进行了更改.现在我得到了错误:

Then i look around the web, found out that i need to change the part to socket. I looked for my socket found it and changed it using unix_socket=/tmp/mysql-1.sock. Now i get the error:

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

我还尝试将主机和主机名更改为承载数据库的服务器的IP地址,但仍然遇到相同的错误.

I have also tried changing the host and hostname to the IP address of server hosting the database and still get the same error.

请有人可以帮助我.我在高迪上托管.

Please can someone help me. Im hosting on godaddy.

谢谢.

编辑#1

$dbh = new PDO('mysql: hostname=122.100.111.0;port=3306;unix_socket=/tmp/mysql-1.sock; dbname=orson', 'username', 'password');
    foreach($dbh->query('SELECT * from q_users') as $row) {
        print_r($row);
    }
    $dbh = null;
} catch (PDOException $e) {
    print "Error!: " . $e->getMessage() . "<br/>";

}

推荐答案

与Godaddy支持团队交换消息后,我发现他们不支持共享托管计划中的PDO.

After exchanging messages with the Godaddy Support Team i found out that they don't support PDO on their shared hosting plan.

这篇关于我在使用PDO连接到Godaddy上的数据库时遇到问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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