postgresql学习

    科技2022-07-11  83

    安装虚拟机

    vmvare workstation (v12)centos (v7)镜像地址:https://mirrors.aliyun.com/centos 参考博文:https://blog.csdn.net/wujiele/article/details/92803655 https://www.cnblogs.com/eric88/articles/10639924.html

    安装postgresql

    参考博文:https://www.cnblogs.com/zll-0405/p/12534165.html 官网地址:https://www.postgresql.org/download/linux/redhat/ 按照提示选择yum安装方式,此次安装版本是v12

    # Install the repository RPM: yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm # Install PostgreSQL: yum install -y postgresql12-server # Optionally initialize the database and enable automatic start: /usr/pgsql-12/bin/postgresql-12-setup initdb systemctl enable postgresql-12 systemctl start postgresql-12

    安装完成后需要配置以下信息

    防火墙开放端口5432编辑postgresql.conf配置文件,如果是默认安装的位置在:/var/lib/pgsql/12/data/。注意是把注释放开即前面的#去掉,不然不生效,listen_addresses设置成*,作用是让postgresql监听所有IP,也可以限定特定IP listen_addresses='*' port=5432 编辑pg_hba.conf,该配置文件与postgresql.conf同目录,配置host 权限,例如只能限定数据库及用户和访问方式 # TYPE DATABASE USER ADDRESS METHOD # "local" is for Unix domain socket connections only local all all peer # IPv4 local connections: host all all 0.0.0.0/0 md5 # IPv6 local connections: host all all ::1/128 ident # Allow replication connections from localhost, by a user with the # replication privilege. local replication all peer host replication all 0.0.0.0/0 md5 host replication all ::1/128 ident

    注意:telnet不通端口5432时,请检查以上信息是否配置正确。

    查看postgre 监听的IP和端口号(postmaster进程只有在postgresql启动状态下才存在,也可grep 5432端口) netstat -atnup | grep postmaster 以下是查看防火墙状态,postgresql的启动状态 systemctl status firewalld systemctl status iptables systemctl status postgresql-12

    安装navicat客户端

    参考博文:https://www.youranshare.com/push/appdown/app-soft/6743.html

    学习PL/pgsql(学习ing)

    官网教程:https://www.postgresqltutorial.com/postgresql-plpgsql/

    Processed: 0.009, SQL: 8