PostgreSql系列一:PG数据库的安装配置启动
yuyutoo 2024-10-24 17:52 9 浏览 0 评论
1 PG数据库的介绍
PostgreSql是一个开源的关系型数据库,最近几年在国内慢慢火起来了.越来越多的公司也都在使用PG数据库,根据DB-Engines 上边的ranking显示.PG的热度已经从20年的第十上升到了第四.那么我们还不赶快学起来么.
2 PG数据库的安装
PG官网有具体的安装方法,可以根据自己具体的操作系统去选择对应的版本.
我的是centos7 选择安装了PG12
PG官网:https://www.postgresql.org/download/
安装过程:
yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
yum install -y postgresql12-server
至此,数据库PG12就算下载下来了
3 配置启动
程序目录在:
[root@slowquery ~]# ll /usr/pgsql-12/
总用量 12
drwxr-xr-x. 2 root root 4096 6月 30 20:14 bin
drwxr-xr-x. 3 root root 4096 6月 30 20:02 lib
drwxr-xr-x. 7 root root 4096 6月 30 20:02 share
默认情况下PG的数据目录是在/var/log下边的,我们可以自定义一下,方便管理
mkdir -p /pgsql/data
useradd postgres
chown -R postgres.postgres /pgsql
3.1 初始化命令理解
官网解释:https://www.postgresql.org/docs/12/app-initdb.html?spm=a2c6h.12873639.0.0.5dcc7145YmBIcC
[root@slowquery ~]# ll /usr/pgsql-12/bin/initdb --help
用法:ls [选项]... [文件]...
List information about the FILEs (the current directory by default).
Sort entries alphabetically if none of -cftuvSUX nor --sort is specified.
Mandatory arguments to long options are mandatory for short options too.
-a, --all 不隐藏任何以. 开始的项目
-A, --almost-all 列出除. 及.. 以外的任何项目
--author 与-l 同时使用时列出每个文件的作者
-b, --escape 以八进制溢出序列表示不可打印的字符
--block-size=SIZE scale sizes by SIZE before printing them; e.g.,
'--block-size=M' prints sizes in units of
1,048,576 bytes; see SIZE format below
-B, --ignore-backups do not list implied entries ending with ~
-c with -lt: sort by, and show, ctime (time of last
modification of file status information);
with -l: show ctime and sort by name;
otherwise: sort by ctime, newest first
-C list entries by columns
--color[=WHEN] colorize the output; WHEN can be 'never', 'auto',
or 'always' (the default); more info below
-d, --directory list directories themselves, not their contents
-D, --dired generate output designed for Emacs' dired mode
-f do not sort, enable -aU, disable -ls --color
-F, --classify append indicator (one of */=>@|) to entries
--file-type likewise, except do not append '*'
--format=WORD across -x, commas -m, horizontal -x, long -l,
single-column -1, verbose -l, vertical -C
--full-time like -l --time-style=full-iso
-g 类似-l,但不列出所有者
--group-directories-first
group directories before files;
can be augmented with a --sort option, but any
use of --sort=none (-U) disables grouping
-G, --no-group 以一个长列表的形式,不输出组名
-h, --human-readable 与-l 一起,以易于阅读的格式输出文件大小
(例如 1K 234M 2G)
--si 同上面类似,但是使用1000 为基底而非1024
-H, --dereference-command-line
follow symbolic links listed on the command line
--dereference-command-line-symlink-to-dir
follow each command line symbolic link
that points to a directory
--hide=PATTERN do not list implied entries matching shell PATTERN
(overridden by -a or -A)
--indicator-style=WORD append indicator with style WORD to entry names:
none (default), slash (-p),
file-type (--file-type), classify (-F)
-i, --inode print the index number of each file
-I, --ignore=PATTERN do not list implied entries matching shell PATTERN
-k, --kibibytes default to 1024-byte blocks for disk usage
-l 使用较长格式列出信息
-L, --dereference 当显示符号链接的文件信息时,显示符号链接所指示
的对象而并非符号链接本身的信息
-m 所有项目以逗号分隔,并填满整行行宽
-n, --numeric-uid-gid 类似 -l,但列出UID 及GID 号
-N, --literal 输出未经处理的项目名称 (如不特别处理控制字符)
-o 类似 -l,但不列出有关组的信息
-p, --indicator-style=slash 对目录加上表示符号"/"
-q, --hide-control-chars print ? instead of nongraphic characters
--show-control-chars show nongraphic characters as-is (the default,
unless program is 'ls' and output is a terminal)
-Q, --quote-name enclose entry names in double quotes
--quoting-style=WORD use quoting style WORD for entry names:
literal, locale, shell, shell-always, c, escape
-r, --reverse 逆序排列
-R, --recursive 递归显示子目录
-s, --size 以块数形式显示每个文件分配的尺寸
-S sort by file size
--sort=WORD sort by WORD instead of name: none (-U), size (-S),
time (-t), version (-v), extension (-X)
--time=WORD with -l, show time as WORD instead of default
modification time: atime or access or use (-u)
ctime or status (-c); also use specified time
as sort key if --sort=time
--time-style=STYLE with -l, show times using style STYLE:
full-iso, long-iso, iso, locale, or +FORMAT;
FORMAT is interpreted like in 'date'; if FORMAT
is FORMAT1<newline>FORMAT2, then FORMAT1 applies
to non-recent files and FORMAT2 to recent files;
if STYLE is prefixed with 'posix-', STYLE
takes effect only outside the POSIX locale
-t sort by modification time, newest first
-T, --tabsize=COLS assume tab stops at each COLS instead of 8
-u with -lt: sort by, and show, access time;
with -l: show access time and sort by name;
otherwise: sort by access time
-U do not sort; list entries in directory order
-v natural sort of (version) numbers within text
-w, --width=COLS assume screen width instead of current value
-x list entries by lines instead of by columns
-X sort alphabetically by entry extension
-1 list one file per line
SELinux options:
--lcontext Display security context. Enable -l. Lines
will probably be too wide for most displays.
-Z, --context Display security context so it fits on most
displays. Displays only mode, user, group,
security context and file name.
--scontext Display only security context and file name.
--help 显示此帮助信息并退出
--version 显示版本信息并退出
SIZE is an integer and optional unit (example: 10M is 10*1024*1024). Units
are K, M, G, T, P, E, Z, Y (powers of 1024) or KB, MB, ... (powers of 1000).
使用色彩来区分文件类型的功能已被禁用,默认设置和 --color=never 同时禁用了它。
使用 --color=auto 选项,ls 只在标准输出被连至终端时才生成颜色代码。
LS_COLORS 环境变量可改变此设置,可使用 dircolors 命令来设置。
退出状态:
0 正常
1 一般问题 (例如:无法访问子文件夹)
2 严重问题 (例如:无法使用命令行参数)
GNU coreutils online help: <http://www.gnu.org/software/coreutils/>
请向<http://translationproject.org/team/zh_CN.html> 报告ls 的翻译错误
要获取完整文档,请运行:info coreutils 'ls invocation'
3.2 自定义初始化
/usr/pgsql-12/bin/initdb -D /pgsql/data
-D 指定初始化数据目录
其他参数默认就好了.PG12默认的校对规则及字符集都支持中文了.不需要去更改
修改启动文件:
vim /usr/lib/systemd/system/postgresql-12.service
修改参数:
Environment=PGDATA=/pgsql/data/ --指定自己刚刚初始化数据的数据目录
保存退出
然后执行
systemctl daemon-reload
3.3 启动数据库
systemctl start postgresql-12.service
数据库已经启动了.可以愉快的进行玩耍了
[root@slowquery ~]# su - postgres
上一次登录:四 7月 1 10:12:51 CST 2021pts/0 上
-bash-4.2$
[root@slowquery ~]# su - postgres
上一次登录:四 7月 1 10:12:51 CST 2021pts/0 上
-bash-4.2$ psql
psql (12.7)
输入 "help" 来获取帮助信息.
postgres=# \db
表空间列表
名称 | 拥有者 | 所在地
------------+----------+--------
pg_default | postgres |
pg_global | postgres |
(2 行记录)
postgres=#
下期预告:PG的架构体系及权限体系 https://www.toutiao.com/i6979921697470235143/
源码安装请看:PG基于源码安装链接
相关推荐
- MATLAB实例讲解—求二元函数的极值
-
实例程序...
- 解析式大赛的获奖作品代码和公式公布啦!
-
上方超级数学建模可加关注传播数学干货,学会理性的方式去思考问题大家期待已久的运行代码终于新鲜出炉了!!!抱歉让各位粉丝久等了接下来就是揭秘奇迹的时刻1、emoji解析式:无代码:holdon...
- 基于MATLAB的ACC控制算法设计及仿真测试
-
作者...
- MATLAB基础学习之坐标转换(matlab改坐标)
-
(一)平面坐标转换1.cart2pol:将笛卡尔坐标转换为极坐标;2.pol2cart:将极坐标转换为笛卡尔坐标;(二)立体坐标转换1.cart2sph:将笛卡尔坐标转换为极坐标;2.sph2cart...
- 「太极创客」零基础入门学用物联网 - MQTT篇 1-9 自我测试
-
到目前为止,我们已经掌握了MQTT通讯的基本流程以及如何使用ESP8266来发布和订阅MQTT消息。这节课我们来进行自我测试。...
- 用豆包改了一下午程序,感觉它聪明得超乎想象
-
之前低估了AI的聪明程度,AI持续学习下去,未来可以做的事情太多了,编程已经算是比较复杂的事情都能完成得这么好,那些项目计划、工作报告更是小儿科。今天用豆包改了几个程序,提出的BUG也能修改完成...
- Node-Media-Server开源流行Nodejs流媒体服务器
-
简介Node-Media-Server一个Node.js实现的RTMP/HTTP/WebSocket/HLS/DASH流媒体服务器。开源github地址:https://github.com/il...
- 如何应对 RAG 开发挑战?12 个痛点逐一击破
-
受到论文《SevenFailurePointsWhenEngineeringaRetrievalAugmentedGenerationSystem》的启发,并结合实际开发RAG(检...
- 团队协作-代码格式化工具clang-format
-
环境:clang-format:10.0.0前言统一的代码规范对于整个团队来说十分重要,通过git/svn在提交前进行统一的ClangFormat格式化,可以有效避免由于人工操作带来的代码格式问题。C...
- 如何编写自己的Arduino库?(arduino怎么自己写库)
-
支持一对一答疑的购买地址...
- Auto CAD 命令(A)(cad命令aaw)
-
ABOUT(命令)显示有关产品的信息。...
- 一文读懂设计模式,看这篇就够了(设计模式是干嘛的)
-
转载:javadoop.com/post/design-pattern一直想写一篇介绍设计模式的文章,让读者可以很快看完,而且一看就懂,看懂就会用,同时不会将各个模式搞混。自认为本文还是写得不错的,花...
- ASL开发者指南:构建健壮高效的C++应用
-
1.库介绍AdobeSourceLibraries(ASL),现在由stlab维护,是一组专注于提供高质量、经过实战检验的C++组件的集合。它最初由Adobe公司开发,旨在解决构建...
- linux下GDB使用方法(linux怎么用gdb调试)
-
gdb是GNU开源组织发布的一个强大的Linux下的程序调试工具。一般来说,GDB主要帮助你完成下面四个方面的功能:1、启动你的程序,可以按照你的自定义的要求随心所欲的运行程序。2、可让被调试的程...
你 发表评论:
欢迎- 一周热门
-
-
前端面试:iframe 的优缺点? iframe有那些缺点
-
带斜线的表头制作好了,如何填充内容?这几种方法你更喜欢哪个?
-
漫学笔记之PHP.ini常用的配置信息
-
其实模版网站在开发工作中很重要,推荐几个参考站给大家
-
推荐7个模板代码和其他游戏源码下载的网址
-
[干货] JAVA - JVM - 2 内存两分 [干货]+java+-+jvm+-+2+内存两分吗
-
正在学习使用python搭建自动化测试框架?这个系统包你可能会用到
-
织梦(Dedecms)建站教程 织梦建站详细步骤
-
【开源分享】2024PHP在线客服系统源码(搭建教程+终身使用)
-
2024PHP在线客服系统源码+完全开源 带详细搭建教程
-
- 最近发表
- 标签列表
-
- mybatis plus (70)
- scheduledtask (71)
- css滚动条 (60)
- java学生成绩管理系统 (59)
- 结构体数组 (69)
- databasemetadata (64)
- javastatic (68)
- jsp实用教程 (53)
- fontawesome (57)
- widget开发 (57)
- vb net教程 (62)
- hibernate 教程 (63)
- case语句 (57)
- svn连接 (74)
- directoryindex (69)
- session timeout (58)
- textbox换行 (67)
- extension_dir (64)
- linearlayout (58)
- vba高级教程 (75)
- iframe用法 (58)
- sqlparameter (59)
- trim函数 (59)
- flex布局 (63)
- contextloaderlistener (56)