• psql备份和恢复(ubuntu)


    备份

    sudo pg_dump -U  username  -f  filename.sql  dbname

    恢复

    psql -U username -f filename.sql dbname

    -------------备份某张表-----------------

    (导出dbname数据库中表tablename的数据,以insert语句的形式)

    sudo pg_dump -U  username  -f  filename.sql -t tablename --column-inserts dbname

    ----------------------------------------------

    --------------------------备份时出现错误 ---------------------------------------

    --------------------------错误提示  Peer authentication failed for user "postgres"

    Peer authentication 是默认的配置,如果你的计算机用户名和你的postgres数据库名是一样的话,那么就不会出现此错误,不需要为你的数据库设置密码。

    还有一种md5 authentication,它需要密码。

    而我的计算机用户名和我的数据库名不一致,所以需要把Peer authentication改成md5 authentication,然后给数据库设置密码

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

    执行命令 

    找到下面的一行:

    local   all             postgres                                peer

    改成

    local   all             postgres                                md5

    然后 service postgresql restart 

  • 相关阅读:
    (33)ElasticSearch文档的核心元数据解析
    (32)ElasticSearch的容错机制
    (31)ElasticSearch水平扩容的过程
    (30)ElasticSearch两个节点环境中创建index解析
    (29)ElasticSearch分片和副本机制以及单节点环境中创建index解析
    UVA
    HDU
    ZOJ
    BZOJ1499: 瑰丽华尔兹(单调队列)
    UVALive
  • 原文地址:https://www.cnblogs.com/tdsun/p/8583865.html
Copyright © 2020-2023  润新知