PostgreSQL11 MYSQL_安装postgresql11.5
初始化数据库
切换用户
[root@localhost build_dir]#su -postgres
初始化数据库
[postgres@localhost~]$ initdb -D $PGDATA -U postgres --locale=en_US.UTF8 -E UTF8
修改监听地址 将listen_addresses的值设置成*,使其监听整个网络,端口号默认是5432,也可以自己设置。
[postgres@localhost~]$ vim /mnt/db1/pgdata/pgsql/postgresql.conf
修改内容:
listen_addresses= '*'unix_socket_directories= '.'port= 8432修改客户端认证方式
[postgres@localhost~]$ vim /mnt/db1/pgdata/pgsql/pg_hba.conf
添加内容:
host all all0.0.0.0/0md5 # 其他用户登陆
设置防火墙规则
#切换回root用户
[postgres@localhost~]$ exit
[root@localhost build_dir]# firewall-cmd --zone=public --add-port=8432/tcp --permanent
[root@localhost build_dir]# firewall-cmd --reload
启动数据库
[root@localhost build_dir]#su -postgres
启动
[postgres@localhost~]$ pg_ctl -D /mnt/db1/pgdata/pgsql -l /mnt/db1/archivelog/pgsql.log start
停止
[root@localhost postgres]# pg_ctl-D /mnt/db1/pgdata/pgsql/ -s -m fast stop
连接测试
[postgres@localhost~]$ psql
查询所有用户
postgres=# select *from pg_user;
postgres=# select *from pg_roles;
查询权限
postgres=# select * from information_schema.table_privileges where grantee='cc';
查看有哪些数据库
postgres=# \l
相当与mysql的show databases;
postgres=# selectdatname from pg_database;
相当于mysql的show tables, public 是默认的schema的名字
postgres=# SELECT table_name FROM information_schema.tables WHERE table_schema = 'public';
相当与mysql的describe table_name,'table_name'是要查询的表的名字
postgres=# SELECT column_name FROM information_schema.columns WHERE table_name ='table_name';
退出
postgres=# \q
psql 是 PostgreSQL 的客户端程序,要连接 PostgreSQL 数据库,我们需要指定以下内容:-d or --dbname 数据库名-h or --host 主机名-p or --port 端口号,默认5432 端口-U or --username 用户名
[postgres@localhost~]$ psql -h localhost -p 8432 -U postgres
设置postgres用户密码
[postgres@localhost~]$ psql
postgres=# ALTER USER postgres WITH encrypted PASSWORD 'new password';
postgres=# \q
[postgres@localhost~]$ psql -h localhost -p 8432 -U postgres
设置开机自启动
设置启动配置
vim/usr/lib/systemd/system/postgresql-11.service
添加内容:
[Unit]
Description=PostgreSQL 11database server
Documentation=https://www.postgresql.org/docs/11/static/
After=syslog.target
After=network.target
[Service]
Type=notify
User=postgres
Group=postgres
# Location of database directory
Environment=PGDATA=/mnt/db1/pgdata/pgsql/# Where to send early-startup messages from the server (before the logging
# options of postgresql.conf take effect)
# This is normally controlled by the global default set by systemd
# StandardOutput=syslog
# Disable OOMkillon the postmaster
OOMScoreAdjust=-1000Environment=PG_OOM_ADJUST_FILE=/proc/self/oom_score_adj
Environment=PG_OOM_ADJUST_VALUE=0# ExecStartPre=/usr/pgsql-11/bin/postgresql-11-check-db-dir${PGDATA}
ExecStart=/usr/local/pgsql/bin/postmaster -D ${PGDATA}
ExecReload=/bin/kill -HUP $MAINPID
# ExecStart=/usr/local/pgsql9.4/bin/pg_ctl start -D ${PGDATA} -s -o "-p ${PGPORT}" -w -t 300# ExecStop=/usr/local/pgsql9.4/bin/pg_ctl stop -D ${PGDATA} -s -m fast
# ExecReload=/usr/local/pgsql9.4/bin/pg_ctl reload -D ${PGDATA} -s
KillMode=mixed
KillSignal=SIGINT
# Do not set any timeout value, so that systemd will notkillpostmaster
# during crash recovery.
TimeoutSec=0[Install]
WantedBy=multi-user.target
添加可执行权限
[root@localhost postgres]#chmod 754 /usr/lib/systemd/system/postgresql-11.service
设置开机自启动
自动启动
[root@localhost postgres]# systemctl enable postgresql-11.service
启动
[root@localhost postgres]# systemctl start postgresql-11.service
停止某服务
[root@localhost postgres]# systemctl stop postgresql-11.service
不自动启动
[root@localhost postgres]# systemctl disable postgresql-11.service
检查服务状态(服务详细信息)
systemctl status postgresql-11.service
检查服务状态(仅显示是否Active)
systemctl is-active postgresql-11.service
显示所有已启动的服务
systemctl list-units --type=service
PostgreSQL11 MYSQL_安装postgresql11.5相关推荐
- centos7 安装postgresql11
1 进入postresql官网下载页面,提示了centos相关下载安装等信息. https://www.postgresql.org/download/linux/redhat/ 2 连接到cento ...
- centos7 go yum 安装_超详细的centos7下载安装Postgresql11(yum安装)教程
概述 新项目准备用PG数据库,实际上也是练手用的,后面用好了再做mysql到PG的迁移,今天主要记录一下centos7用yum安装Postgresql11的过程. 1.到官网查看yum支持到哪个版本的 ...
- Windows安装PostgreSQL11.1
Windows安装PostgreSQL11.1 安装过程如下: 1.下载安装包postgresql-11.1-1-windows-x64.exe 2.点击下一步 3.选择安装位置,默认路径C:\Pro ...
- mysqluc安装MYSQL_安装mysql几种方法
一.在线安装(推荐) 1.配置仓库 [root@localhost ~]# vim /etc/yum.repos.d/mysql.repo 1 2.安装指定版本(提前配置好网络源) [root@loc ...
- lnmp中怎么运行ngin和mysql_安装LNMP(Nginx+Mysql+PHP)
1:安装nginx yum install -y gcc pcre-devel openssl-devel wget http://www.nginx.org/download/nginx-1.4.2 ...
- busybox 安装mysql_安装busybox
安装busybox按以下步骤即可: 1.root手机 2.查看手机支持的cpu架构:cat /system/build.prop | grep abi 我手机查出来的结果如下所示: ro.produc ...
- powerdns mysql_安装PowerDNS(使用MySQL后端)和Poweradmin在Debian Lenny
安装PowerDNS(带MySQL后端)和Poweradmin在Debian Lenny上 本文介绍如何在Debian Lenny系统上安装PowerDNS名称服务器(使用MySQL后端)和Power ...
- wdcp安装mysql_安装wdCP,无法连接mysql,解决方法
安装wdCP,无法连接mysql,解决方法 在ubuntu 12.04版本上安装wdCP,采用编译安装的方式,一路装下来最后悲催地报错了: ERROR 2002 (HY000): Can't conn ...
- php源码怎样安装mysql_安装MySQL
三.mysql的安装,与php.Apache相结合 打开下载的文件,双击运行,出现如下界面. mysql安装向导启动,按"Next"继续. 选择安装类型,有"Typica ...
最新文章
- HP 服务器使用 SmartStart CD 引导安装 windows 2008 操作系统
- LeetCode5382. HTML 实体解析器
- PHP算法向数组的头插入带键的元素
- ae导出json_关于AE转json动画开发避坑指南
- 一文理清RocketMQ顺序消费、重复消费、消息丢失问题
- 如何在Java 8中使用filter()方法
- 60分钟快速入门 PyTorch
- Java编码与乱码问题
- Android使用软引用和弱引用
- python之提升程序性能的解决方案
- 解决margin-top塌陷问题的六种方法
- 双网卡mode6模式 同时工作 冗余互备
- maven内置属性详细说明
- BZOJ4602: [Sdoi2016]齿轮(并查集 启发式合并)
- Dictionary 索引超出数组界限
- 身份证扫描件用手机怎么弄?手把手教你生成电子身份证
- VC6.0 快捷键整理
- 深度学习基础知识(八):神经网络基础之导数
- javascript成神之路(1):如何编写高质量的js代码
- 柠季这杯“催熟”的茶,你会喝几次?
热门文章
- PCB中MARK点画法与注意事项
- sqlmap之sql注入(一)
- 快应用开发心得——新手入门指南
- 学python必须得英语精通吗_Python无用武之地?只能说你是真的没有精通Python语言(附教程)...
- 类加载(基本说明、流程图、类加载各个阶段完成的任务)
- SE、ECA、CA、SA、CBAM、ShuffleAttention、SimAM、CrissCrossAttention、SK、NAM、GAM、SOCA注意力模块、程序
- 【笔记】磁盘管理(2):磁盘分区、增加swap
- 2022客户体验管理白皮书
- 小熊维尼项目冲刺 第二天
- npm WARN webpack-cli@3.3.11 requires a peer of webpack@4.x.x but none is installed. You must install