要访问 psql,我必须先登录到另一个 Unix 帐户
sudo su - postgres
那我可以做
postgres@linux ~ $ psql
psql (9.1.10)
Type "help" for help.
postgres=#
但是,我不明白为什么需要 postgres Unix 帐户(当我执行 sudo su - postgres 时)。仅从我原来的 Unix 帐户运行“psql”有什么问题?
postgres Unix 和命令行是否共享相同的密码?
*我是 Linux/postgres 的新手,所以请随意给出基本解释
编辑:另一个问题:
有什么区别
postgres=#
和
postgres-#
However, I don't understand why the postgres Unix account (when I do sudo su - postgres) is necessary. What's wrong with just running "psql" from my original Unix account?
And do the postgres Unix and command line share the same password?
Postgres 用户无法登录,只能读取/写入它拥有的任何内容,除非您创建它或以其他方式配置您的计算机。
这就是它存在的原因:安全性。这不是技术上的要求(例如,OSX 上的自制软件将使用您自己的用户名),而是最佳实践——尤其是在服务器上。