zoukankan      html  css  js  c++  java
  • linux下postgresql安装

    1、下载地址
    https://www.enterprisedb.com/download-postgresql-binaries
    

      

     

    2、创建用户并修改密码
    [root@node01 ~]# useradd postgres
    [root@node01 ~]# passwd postgres
    Changing password for user postgres.
    New password:
    BAD PASSWORD: The password contains the user name in some form
    Retype new password:
    passwd: all authentication tokens updated successfully.
    [root@node01 ~]# id postgres
    uid=1000(postgres) gid=1000(postgres) groups=1000(postgres)
    
    3、创建目录并授权
    [root@node01 ~]# mkdir /software/pgsql_data            ---------数据目录
    [root@node01 ~]# mkdir -p /stage                       ---------软件安装目录
    [root@node01 ~]# chown -R postgres.postgres /software*
    [root@node01 ~]# chown -R postgres.postgres /stage*
    
    4、切换postgres用户,并解压安装包
    [root@node01 stage]# su - postgres
    [postgres@node01 ~]$ cd /stage/
    [postgres@node01 stage]$ ll
    total 156744
    -rw-r--r-- 1 postgres postgres 160504039 Aug 17 23:11 postgresql-10.14-1-linux-x64-binaries.tar.gz
    [postgres@node01 stage]$ tar -xvf postgresql-10.14-1-linux-x64-binaries.tar.gz
    
    5、初始化
    [postgres@node01 stage]$ /stage/pgsql/bin/initdb -D /software/pgsql_data
    The files belonging to this database system will be owned by user "postgres".
    This user must also own the server process.
    
    The database cluster will be initialized with locale "en_US.UTF-8".
    The default database encoding has accordingly been set to "UTF8".
    The default text search configuration will be set to "english".
    
    Data page checksums are disabled.
    
    fixing permissions on existing directory /software/pgsql_data ... ok
    creating subdirectories ... ok
    selecting default max_connections ... 100
    selecting default shared_buffers ... 128MB
    selecting default timezone ... PRC
    selecting dynamic shared memory implementation ... posix
    creating configuration files ... ok
    running bootstrap script ... ok
    performing post-bootstrap initialization ... ok
    syncing data to disk ... ok
    
    WARNING: enabling "trust" authentication for local connections
    You can change this by editing pg_hba.conf or using the option -A, or
    --auth-local and --auth-host, the next time you run initdb.
    
    Success. You can now start the database server using:
    
        /stage/pgsql/bin/pg_ctl -D /software/pgsql_data -l logfile start
    
    6、启动数据库
    [postgres@node01 stage]$ /stage/pgsql/bin/pg_ctl -D /software/pgsql_data -l logfile start
    waiting for server to start.... done
    server started
    
    7、登陆数据库
    [postgres@node01 stage]$ psql -Upostgres -dpostgres
    psql.bin (10.14)
    Type "help" for help.
    
    postgres=#
    
    8、关闭数据库
    [postgres@node01 stage]$ /stage/pgsql/bin/pg_ctl -D /software/pgsql_data -l logfile stop
    waiting for server to shut down.... done
    server stopped
    
    9、扩展
    postgres=# l                                ---------列出所有的database
    postgres=# c test                           ----------选择database
    test=# d                                    ----------列出所用database的表
    test=# d tablename                          ----------查看表结构
    test=# q                                    ---------退出登陆
    

      

  • 相关阅读:
    2021“MINIEYE杯”中国大学生算法设计超级联赛(4)
    Spring Boot从入门到精通(十一)集成Swagger框架,实现自动生成接口文档
    Spring Cloud 从入门到精通(二)集成 Nacos 构建微服务实现服务注册
    Spring Cloud 从入门到精通(一)Nacos 服务中心初探
    Apache HBase 1.7.1 发布,分布式数据库
    DB2 SQL Error: SQLCODE=-668, SQLSTATE=57016错误解决方法
    脱离OBDeploy工具,手工部署OceanBase方法
    剑指Offer26.树的子结构
    剑指Offer21.调整数组顺序使奇数偶数前面
    剑指Offer14-I|LeetCode343.剪绳子|整数拆分
  • 原文地址:https://www.cnblogs.com/orcl-2018/p/13518480.html
Copyright © 2011-2022 走看看