获取错误:";Unix域套接字上的连接”/var/run/postgresql/.s.PGSQL.5432“&引用;尝试在centos上使用postgresql创建用户时
完全错误:获取错误:";Unix域套接字上的连接”/var/run/postgresql/.s.PGSQL.5432“&引用;尝试在centos上使用postgresql创建用户时,postgresql,centos,Postgresql,Centos,完全错误: Creating 'pcore' PostgreSQL user... psql: could not connect to server: No such file or directory Is the server running locally and accepting connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"? Connecting to PostgreSQ
Creating 'pcore' PostgreSQL user... psql: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
Connecting to PostgreSQL as 'pcore'...
** Error occurred during execution: FATAL: Ident authentication failed for user "pcore"
postgresql:
psql -U postgres template1
psql (8.4.9)
Type "help" for help.
template1=# \l
List of databases
Name | Owner | Encoding | Collation | Ctype | Access privileges
-----------+----------+----------+-------------+-------------+-----------------------
postgres | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
template0 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/postgres
: postgres=CTc/postgres
template1 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/postgres
: postgres=CTc/postgres
(3 rows)
linux:
lsb_release -a
LSB Version: :core-4.0-ia32:core-4.0-noarch:graphics-4.0-ia32:graphics-4.0-noarch:printing-4.0-ia32:printing-4.0-noarch
Distributor ID: CentOS
Description: CentOS release 5.7 (Final)
Release: 5.7
Codename: Final
此外:
/etc/passwd中没有用户pcore
postgresql希望linux用户和postgresql用户之间进行一对一匹配,这可能是问题所在吗
发生此错误时,我正在尝试创建用户:
# Database imports
import pgdb as psql
# This will create the 'pcore' user using `su` to run the
# command as the postgres system user
def createPsqlPcoreUser(new_pass):
print "Creating 'pcore' PostgreSQL user...",
sys.stdout.flush()
cmd_list = ['su', '-', 'postgres', '-c','psql --host=%s -c '\
'"CREATE USER pcore WITH PASSWORD \'%s\' CREATEDB"' % \
(PSQL_SOCKET_PATH, new_pass)]
p1 = subprocess.Popen(cmd_list,
stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
p1.wait()
print p1.communicate()[0]
此外:
sudo -u postgres createuser pcore -P
Enter password for new role:
Enter it again:
Shall the new role be a superuser? (y/n) y
createuser: could not connect to database postgres: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
[root@localhost pcore]# service postgresql status
postmaster (pid 28901 28900 28899 28898 28896 28894) is running...
[root@localhost pcore]# ps -ef | grep post
postgres 28894 1 0 00:21 ? 00:00:00 /usr/bin/postmaster -p 5432 -D /var/lib/pgsql/data
postgres 28896 28894 0 00:21 ? 00:00:00 postgres: logger process
postgres 28898 28894 0 00:21 ? 00:00:00 postgres: writer process
postgres 28899 28894 0 00:21 ? 00:00:00 postgres: wal writer process
postgres 28900 28894 0 00:21 ? 00:00:00 postgres: autovacuum launcher process
postgres 28901 28894 0 00:21 ? 00:00:00 postgres: stats collector process
令人着迷的错误。看起来您的用户能够正确连接到套接字,但postgres用户不能。我觉得这很奇怪。我的猜测是postgres用户的个人资料有问题 我建议首先使用printenv作为普通用户和postgres用户,并对它们进行比较。特别是PGPORT和PGHOST变量,因为它们可以确定套接字位置。这是第一个开始的地方
其次,您可以检查postgresql.conf中的套接字目录,并将PGHOST设置为绝对目录路径。这可能会解决您的问题,但您的系统的用户帐户级别出现了问题。令人着迷的错误。看起来您的用户能够正确连接到套接字,但postgres用户不能。我觉得这很奇怪。我的猜测是postgres用户的个人资料有问题 我建议首先使用printenv作为普通用户和postgres用户,并对它们进行比较。特别是PGPORT和PGHOST变量,因为它们可以确定套接字位置。这是第一个开始的地方
其次,您可以检查postgresql.conf中的套接字目录,并将PGHOST设置为绝对目录路径。这可能会解决您的问题,但系统的用户帐户级别出现了问题。第一个错误:某些应用程序试图创建(postgres)用户,但无法连接。第二个错误是:应用程序试图以不存在的用户身份连接。您运行了什么导致了错误?附加到问题,由于注释部分缺少格式,我认为这与PGDATA有关,不在预期位置列出的第一个错误和最后一个错误之间存在明显差异(在附加项下)。这表明很难找到Unix套接字。第一个是查找套接字
/var/run/postgresql/.s.PGSQL.5432
,第二个是/tmp/.s.PGSQL.5432
。通过在postgresql.conf中查找字段“Unix\u socket\u directory”来检查应该在哪里找到它(可能位于/etc/postgresql//)。然后通过执行ls-lA socket\u dir
检查它是否确实在那里。第一个错误:某些应用程序试图创建(postgres)用户,但无法连接。第二个错误是:应用程序尝试以不存在的用户身份连接。您运行的是什么导致了此错误?附加到问题后,由于注释部分中缺少格式,我认为这与PGDATA有关,不在预期位置列出的第一个错误与实际错误之间存在明显差异ast错误(在另一个下方)。这表明很难找到Unix套接字。第一个是查找套接字/var/run/postgresql/.s.PGSQL.5432
,第二个是/tmp/.s.PGSQL.5432
。通过在postgresql.conf中查找字段“Unix\u socket\u directory”来检查应该在哪里找到它(可能位于/etc/postgresql//)。然后通过执行ls-lA socket\u dir
检查它是否在那里。
sudo -u postgres createuser pcore -P
Enter password for new role:
Enter it again:
Shall the new role be a superuser? (y/n) y
createuser: could not connect to database postgres: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
[root@localhost pcore]# service postgresql status
postmaster (pid 28901 28900 28899 28898 28896 28894) is running...
[root@localhost pcore]# ps -ef | grep post
postgres 28894 1 0 00:21 ? 00:00:00 /usr/bin/postmaster -p 5432 -D /var/lib/pgsql/data
postgres 28896 28894 0 00:21 ? 00:00:00 postgres: logger process
postgres 28898 28894 0 00:21 ? 00:00:00 postgres: writer process
postgres 28899 28894 0 00:21 ? 00:00:00 postgres: wal writer process
postgres 28900 28894 0 00:21 ? 00:00:00 postgres: autovacuum launcher process
postgres 28901 28894 0 00:21 ? 00:00:00 postgres: stats collector process