时间:2022-02-25来源:www.pcxitongcheng.com作者:电脑系统城
| 1 2  | 
			yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpmyum install -y postgresql13-server | 
		
先创建postgresql储存目录
| 1 2  | 
			mkdir /home/pgsql-13chmod 777 /home/pgsql-13  #授予权限,否则后续初始化是会报错 | 
		
切换postgres用户正式初始化
| 1 2  | 
			su postgres     /usr/pgsql-13/bin/initdb -D /home/pgsql-13/data | 
		

| 1 2  | 
			cd  /home/pgsql-13/usr/pgsql-13/bin/pg_ctl -D /home/pgsql-13/data -l logfile start | 
		
这里注意继续使用postgres用户操作,否则会报错

| 1 2 3 4 5 6 7  | 
			vi /home/pgsql-13/data/postgresql.conflisten_addresses = ‘localhost'   #开放本地登录port = 5432          #开放登录端口psqlALTER USER postgres WITH PASSWORD '(123456)'; #将123456替换成自己设定的数据库密码CREATE DATABASE mytest;  #创建数据库\q  #退出操作 | 
		
结果如下图:

| 1 2  | 
			vi /home/pgsql-13/data/pg_hba.confhost       all       all        0.0.0.0/0      md5  #结尾处添加 | 
		

| 1 2  | 
			mkdir /home/pgsql-13/binvi /home/pgsql-13/bin/startup.sh | 
		
输入一下内容:
| 1 2 3 4 5 6  | 
			#! /bin/bashsu postgres<<!cd /home/pgsql-13/usr/pgsql-13/bin/pg_ctl -D /home/pgsql-13/data -l logfile startexit $?! | 
		
添加脚本路径
| 1 2 3  | 
			chmod -R 755 startup.shvi /etc/rc.local/home/pgsql-13/bin/startup.sh #在文件内容最后一行添加 | 
		
| 1 2 3 4  | 
			mkdir -p /home/pgsql-13/backdatachmod 777 /home/pgsql-13/backdatamkdir -p /home/pgsql-13/backdata/binvi  /home/pgsql-13/backdata/bin/backup.sh | 
		
输入如下内容:
| 1 2 3 4 5  | 
			#! /bin/basht=KaTeX parse error: Expected group after '_' at position 112: …ip > backupfile_̲t.sql.gzfind /home/pgsql-13/backdata -mtime 7 -type f|xargs rm -fexit $?! | 
		
配置定时任务:
| 1 | 12 2 * * * /home/pgsql-13/backdata/bin/backup.sh | 
		
参考网站:https://www.postgresql.org/download/linux/redhat/
PostgreSQL 13.1 手册 http://postgres.cn/docs/13/index.html
到此这篇关于Centos8-stream安装PostgreSQL13的文章就介绍到这了。
2022-09-11
Windows 系统 PostgreSQL 手工安装配置方法教程图解2021-04-22
自定义函数实现单词排序并运用于PostgreSQL(实现代码)2021-04-19
MySQL命令行操作时的编码问题详解玩游戏的时候最怕跳出什么程序来干扰游戏,很多玩家在玩游戏过程中会遇到输入法弹出来,影响游戏体验,Win10玩游戏老跳出来输入法怎么办?按照以下的方法操作就可以解决这个问题了...
2021-02-19