使用rails中的postgresql编辑hba_file

时间:2016-04-13 13:15:12

标签: ruby-on-rails postgresql

我已经在我的rails应用程序中将postgresql安装为数据库。我在配置数据库时遇到问题。我跟着堆栈溢出帖子,想出了如何创建用户和创建数据库。问题是验证用户。我知道这涉及配置hba_file;

我运行以下命令打开配置文件。

sudo vi /etc/postgresql/9.3/main/pg_hba.conf

我知道我必须编辑hba_file中的以下行。我需要更改peer to md5.

#Unix域名套接字的数据库管理登录

local   all             postgres                                peer

我找到了该文件,但编辑文件时遇到了很多麻烦。我按I插入/编辑新值。我不知道如何保存文件。我关闭终端并再次打开文件。我收到以下错误。

E325: ATTENTION
Found a swap file by the name "/etc/postgresql/9.3/main/.pg_hba.conf.swp"
          owned by: root   dated: Wed Apr 13 01:26:42 2016
         file name: /etc/postgresql/9.3/main/pg_hba.conf
          modified: YES
         user name: root   host name: kpauls-scorecliq-2942283
        process ID: 32423
While opening file "/etc/postgresql/9.3/main/pg_hba.conf"
             dated: Wed Mar 16 04:06:59 2016

(1) Another program may be editing the same file.  If this is the case,
    be careful not to end up with two different instances of the same
    file when making changes.  Quit, or continue with caution.
(2) An edit session for this file crashed.
    If this is the case, use ":recover" or "vim -r /etc/postgresql/9.3/main/pg_hba.conf"
    to recover the changes (see ":help recovery").
    If you did this already, delete the swap file "/etc/postgresql/9.3/main/.pg_hba.conf.swp"
    to avoid this message.

Swap file "/etc/postgresql/9.3/main/.pg_hba.conf.swp" already exists!
[O]pen Read-Only, (E)dit anyway, (R)ecover, (D)elete it, (Q)uit, (A)bort:

我不确定如何编辑hba_file文件并保存更改。我了解如何创建用户和创建数据库。但是,我很难编辑文件。我不知道如何编辑和保存文件。我在堆栈上阅读了有关此主题的几篇帖子,但他们并没有真正解释如何编辑文件。任何有关这方面的帮助将不胜感激。谢谢!

0 个答案:

没有答案