PDO连接到本地主机(未知的mysql服务器主机) [英] PDO connect to localhost (unknown mysql server host)

查看:172
本文介绍了PDO连接到本地主机(未知的mysql服务器主机)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以使用具有相同凭据的mysql_*函数连接到MySQL.

I can connect to MySQL using mysql_* functions with the same credentials.

是否可以通过仅具有USAGE特权的用户使用PDO连接到本地MySQL数据库?我没有机会将权限设置为ALL,我已将其阅读为SO中类似问题的解决方案.

Is there any way to connect to a local MySQL database using PDO with a user that has USAGE privilege only? I don't have opportunity to set the rights to ALL, which I've read as a solution to a similar problem here in SO.

SQLSTATE[HY000] [2005] Unknown MySQL server host 'localhost,dbname=crmdb' (74)

推荐答案

 // PDO
$pdo = new PDO("mysql:host=localhost;dbname=database", 'username', 'password');

注意半冒号;不是逗号,

这篇关于PDO连接到本地主机(未知的mysql服务器主机)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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