【发布时间】:2017-06-26 01:13:11
【问题描述】:
我正在使用以下连接来连接没有数据库的 Postgres SQL,因为我需要稍后获取所有数据库名称以进行配置
try{
$this->connection = new \PDO($this->database.":host=".$this->host,$this->user,$this->password);
$this->connection->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
return $this->connection;
}catch(\PDOException $e){
echo $e->getMessage();
}
但我收到以下错误
SQLSTATE[08006] [7] FATAL: database "admin" does not exist
以下是属性中设置的值:
$this->database = pgsql
$this->host = localhost
$this->user = admin
$this->password = admin
任何人都可以帮我解决如何在不使用 PHP PDO 选择任何数据库的情况下连接到 Postgres SQL
【问题讨论】:
-
使用数据库
postgres连接到更多列表数据库 -
使用数据库 pgsql。数据库名称不同。
-
@Deep ya 我提到的是数据库类型,如 MySQL、postgres
-
尝试使用该用户配置文件使用 pgsql 客户端登录,看看是否会出现同样的错误
标签: php postgresql pdo