postgresql – 重启vm后无法访问数据库
我在VM中有这个数据库,可以重新启动VM,它可以正确访问
但是现在如果我在尝试通过pgAdmin III访问数据库时重新启动VM,我会收到以下消息
我通过VM快照进行了一些测试,并注意到在命令之后发生了这种行为 sudo a2enmod重写 但我没有发现任何可能表明某些链接或如何解决的问题,因为我需要运行sudo a2enmod重写 postgresql.conf连接设置: # - Connection Settings - listen_addresses = '*' # what IP address(es) to listen on; # comma-separated list of addresses; # defaults to 'localhost'; use '*' for all # (change requires restart) port = 5432 # (change requires restart) max_connections = 100 # (change requires restart) #superuser_reserved_connections = 3 # (change requires restart) unix_socket_directories = '/var/run/postgresql' # comma-separated list of directories # (change requires restart) #unix_socket_group = '' # (change requires restart) #unix_socket_permissions = 0777 # begin with 0 to use octal notation # (change requires restart) #bonjour = off # advertise server via Bonjour # (change requires restart) #bonjour_name = '' # defaults to the computer name # (change requires restart) 我已经尝试重新启动postgres服务,但它没有用
这是调试对任何数据库的访问的一般过程的一部分.
旨在确定服务是否正常运行. 检查PostgreSQL是否正在运行: pgrep -fl postgres service postgresql status (如果您的Linux中有状态,那么您应该看到类似的内容): mortiz@florida:~/.mozilla/firefox/hlmpduzp.default$sudo service postgresql status ● postgresql.service - PostgreSQL RDBMS Loaded: loaded (/lib/systemd/system/postgresql.service; enabled; vendor preset: enabled) Active: active (exited) since Mon 2018-06-11 14:05:04 -03; 3s ago Process: 17522 ExecStart=/bin/true (code=exited,status=0/SUCCESS) Main PID: 17522 (code=exited,status=0/SUCCESS) Jun 11 14:05:04 florida systemd[1]: Starting PostgreSQL RDBMS... Jun 11 14:05:04 florida systemd[1]: Started PostgreSQL RDBMS. 如果服务正在运行,请检查端口的基本连接: telnet 127.0.0.1 5432 如果您无法连接尝试使用localhost或IP地址(而不是环回): telnet localhost 5432 telnet <your_ip_address> 5432 >如果服务未运行,请尝试恢复postgresql.conf备份. 如果您能够使用telnet连接到端口,那么服务已启动且端口已打开,无论如何,实例或客户端可能存在配置问题. 如果telnet不能用于127.0.0.1但是它使用localhost或 – (your_ip_address / not loopback),那么在客户端设置中更改它. 如果服务正在运行,实例或客户端可能存在配置问题. 如果telnet不能与127.0.0.1一起使用,但它使用localhost,或者在客户端设置中更改.
检查服务的预期行为.在Linux中,某些服务即使出现错误也会启动并产生不良行为. 现在是时候看看服务是否正常工作,我们将使用CLI.运行此命令: psql -h localhost --username=postgres --list 你应该看到数据库列表: mortiz@florida:~/.mozilla/firefox/hlmpduzp.default$psql -h localhost --username=postgres --list Password for user postgres: List of databases Name | Owner | Encoding | Collate | 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) 如果这样可行,那么您的问题可能在客户端pgAdmin中.尝试安装其他客户端或版本并尝试连接到数据库.
小心,先备份你的文件.检查允许连接/方法和用户的PostgreSQL客户端身份验证配置文件主机 – > /etc/postgresql/9.6/main/pg_hba.conf # This file controls: which hosts are allowed to connect,how clients # are authenticated,which PostgreSQL user names they can use,which # databases they can access. Records take one of these forms: # # local DATABASE USER METHOD [OPTIONS] # host DATABASE USER ADDRESS METHOD [OPTIONS] # hostssl DATABASE USER ADDRESS METHOD [OPTIONS] # hostnossl DATABASE USER ADDRESS METHOD [OPTIONS] # METHOD can be "trust","reject","md5","password","gss","sspi",# "ident","peer","pam","ldap","radius" or "cert". Note that # "password" sends passwords in clear text; "md5" is preferred since # it sends encrypted passwords. 如果有任何问题,请告诉我你每次测试的结果. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |