我正在尝试从 bash 文件执行一些 postgres 命令。
我正在尝试通过编写以下行来删除架构
DROP SCHEMA "xxx" IF EXISTS
Run Code Online (Sandbox Code Playgroud)
我这里有两个问题
我不确定如何指定应从中删除架构的数据库
我收到以下错误消息——“DROP: command not found”
谁能帮我解决这个问题?
我在我的 centos vps 中使用 postgre 收到此错误
无法连接到 PostgreSQL 服务器:致命:没有主机“::1”、用户“xxx”、数据库“xxx_xxx”的 pg_hba.conf 条目,SSL 关闭
这是我的 pg_hba.conf
local all all md5
host all all 127.0.0.1/32 md5
Run Code Online (Sandbox Code Playgroud)
一切似乎都正确,但无论我创建和设置什么用户,总是会出现此错误。
我正在建立一个非常小的网络应用程序,我希望最终能成长为更大的应用程序。目前这是一个接近零预算的个人项目,所以我没有太多资源可以投入。如果我开始看到一些成功,我确实希望以一种能够扩大规模的方式进行设置。
我打算使用 PostgreSQL 作为数据库在 EC2 上设置一个带有 Rails 应用程序的微型实例。我是 EC2 的新手,对设置服务器的过程感到非常困惑。
我已经阅读了足够多的内容,知道通常不推荐在 Micro 实例上运行 PostgreSQL,在同一实例上运行 Web 服务器更不推荐,但此时性能不是什么大问题(我现在只有 3 个用户! )。正常运行时间更重要,但并不重要。关键是数据库的完整性和可靠性。
据我所知,只需在 EC2 实例上设置默认 PostgreSQL 安装即可,但如果实例终止,数据就会消失。我想知道的是;
如何设置 PostgreSQL 以将其数据存储在可以持久存在的地方?
如何设置连续备份,以便始终有我的用户数据的另一个副本?
我意识到这些问题都不是微不足道的,但只要指出正确的方向就会有很大的帮助,因为这是一个让我思考的相当大的话题。
目前我在远程开发服务器上开发。我通过 SSH 连接到开发服务器(使用 SSH 密钥)作为
ssh -p 22222 user@devbox.com
Run Code Online (Sandbox Code Playgroud)
然后从开发服务器,我通过本地网络连接到数据库
psql -U postgres -h psqldb -d my_database
Run Code Online (Sandbox Code Playgroud)
wherepsqldb指向10.0.0.202开发服务器的/etc/hosts文件。
我想在我自己的电脑上开始本地开发。如何psqldb通过使用远程开发服务器作为 SSH 隧道从本地机器连接到Postgres 服务器(或者有更好的方法来做到这一点)?
编辑
我没有提到我已经在本地服务器上安装了 Postgres 并在默认端口 5432 上监听。
我的本地可以连接到远程,但它无法连接到 dbserver。远程可以连接到 dbserver(使用 psql)。
我想从我的本地对数据库运行 sql 脚本。
我正在寻找一种在远程打开 psql 并使用 ssh 将我的 stdin 和 stdout 定向到我的本地的方法。
现在在愚蠢的选项中,我这样做:
ssh remote
psql -h db report
password
run my commands
Run Code Online (Sandbox Code Playgroud)
我可以通过这种方式在脚本中完成它,但它丑陋且不允许我与 psql 进行交互会话。
PSQL="PGPASSWORD=mypassword psql -h dbserver -d report"
SQL="SELECT 1"
ssh remote "$PSQL --command 'COPY ($SQL) TO STDOUT WITH CSV;'"
Run Code Online (Sandbox Code Playgroud)
Ps-Python 也可以。
我一直想知道sudo reboot运行 Postgres(即 9.2.4)的服务器是否会(或肯定会)导致数据丢失或其他问题(例如,无法在系统启动时再次启动服务器)。或者,确实reboot向进程发送适当的信号以允许它们正确关闭(例如,包括允许完成事务等)。
我试过了
sudo apt-get purge postgresql
sudo apt-get autoremove postgresql
Run Code Online (Sandbox Code Playgroud)
和
sudo apt-get --purge remove postgresql
Run Code Online (Sandbox Code Playgroud)
但在这之后dpkg -l | grep postgres给了我:
pi postgresql-9.1 9.1.11-0ubuntu0.13.04 amd64 object-relational SQL database, version 9.1 server
pi postgresql-client-9.1 9.1.11-0ubuntu0.13.04 amd64 front-end programs for PostgreSQL 9.1
ii postgresql-client-common 140 all manager for multiple PostgreSQL client versions
ii postgresql-common 140 all PostgreSQL database-cluster manager
ii postgresql-contrib 9.1+140 all additional facilities for PostgreSQL (supported version)
ii postgresql-contrib-9.1 9.1.11-0ubuntu0.13.04 amd64 additional facilities for PostgreSQL
ii postgresql-doc-9.1 9.1.11-0ubuntu0.13.04 all …Run Code Online (Sandbox Code Playgroud) 我在 16GB 的 Linode(Ubuntu 12.04 32 位)上运行专用的 PostgreSQL。我试过使用 pgtune,但我会遇到共享内存错误。IE
The PostgreSQL server failed to start. Please check the log output:
2014-02-10 08:32:39 EST FATAL: could not create shared memory segment: Invalid argument
2014-02-10 08:32:39 EST DETAIL: Failed system call was shmget(key=5432001, size=4107419648, 03600).
2014-02-10 08:32:39 EST HINT: This error usually means that PostgreSQL's request for a shared memory segment exceeded your kernel's SHMMAX parameter. You can either reduce the request size or reconfigure the kernel with larger SHMMAX. To reduce …Run Code Online (Sandbox Code Playgroud) 如何从 RDS Postgres 实例中删除日志?我刚刚注意到我的实例正在显示消息storage-full. 我可以找到有关如何删除日志文件的任何描述,我认为这是存储已满的原因。数据库中的数据在 ~50MB 范围内。
这是我登录 AWS 时在 RDS 仪表板上看到的消息:

使用 mac OSX Yosemite 10.10.1。我用自制软件卸载并重新安装了 postgres 和 postgis。我知道 postgres 正在寻找 postgis 控制文件的错误位置。还注意到 'which psql' 路径似乎不正确。我如何/在哪里解决这个问题?
查询语句
(9.4.0, server 9.3.5)
ERROR: could not open extension control file "/usr/local/Cellar/postgresql/9.3.5_1/share/postgresql/extension/postgis.control": No such file or directory
Run Code Online (Sandbox Code Playgroud)
find /usr -name postgis.control
/usr/local/Cellar/postgresql/9.4.0/share/postgresql/extension/postgis.control
Run Code Online (Sandbox Code Playgroud)
哪个 psql
/usr/local/bin/psql
Run Code Online (Sandbox Code Playgroud)
哪个 pg_config
/usr/local/bin/pg_config
Run Code Online (Sandbox Code Playgroud)
酿造信息postgis
postgis: stable 2.1.5, HEAD
http://postgis.net
/usr/local/Cellar/postgis/2.1.5 (45 files, 8.6M) *
Built from source
From: https://github.com/Homebrew/homebrew/blob/master/Library/Formula/postgis.rb
Run Code Online (Sandbox Code Playgroud)
酿造信息 postgres
postgresql: stable 9.4.0 (bottled)
http://www.postgresql.org/
Conflicts with: postgres-xc
/usr/local/Cellar/postgresql/9.4.0 (3049 files, 74M) *
Poured from bottle
From: https://github.com/Homebrew/homebrew/blob/master/Library/Formula/postgresql.rb
Run Code Online (Sandbox Code Playgroud)
.bashrc …
postgresql ×10
ssh ×2
ubuntu ×2
32-bit ×1
amazon-ec2 ×1
amazon-rds ×1
centos ×1
log-files ×1
postgis ×1
psql ×1
shell ×1
ssh-tunnel ×1
ubuntu-12.04 ×1
vps ×1