gpt4 book ai didi

shell - 如何在 postgres 中使用 shell 脚本触发 VACUUM 命令

转载 作者:行者123 更新时间:2023-12-04 16:16:50 25 4
gpt4 key购买 nike

这是我的shell脚本

    #!/bin/bash
psql --host=127.0.0.1 --port=5432 --dbname=SIEM --username=dbauser
vacuumdb --analyze --verbose --table 'vuln' SIEM

但它不能正常工作并给出错误:

   linux-lxh4:/home/gaurav # ./script.sh 
psql (9.2.5)
Type "help" for help.

SIEM=# \q
vacuumdb: could not connect to database root: FATAL: Peer authentication failed for user "root"

Edit1:我使用了这段代码:

   psql --host=127.0.0.1 --port=5432 --dbname=SIEM --username=dbauser
VACUUM FULL VERBOSE vuln

这里是错误:

   ./script.sh: line 4: VACUUM: command not found

最佳答案

来自 Postgres VACUUM documentation

管理命令称为 vacuum 而不是 vacuumdb

我这里没有psql但是应该是

#!/bin/bash
psql --host=127.0.0.1 --port=5432 --dbname=SIEM --username=dbauser
-c 'VACUUM VERBOSE ANALYZE vuln'

关于shell - 如何在 postgres 中使用 shell 脚本触发 VACUUM 命令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31285732/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com