centos安装postgresql

参考

https://www.postgresql.org/download/

https://www.postgresql.org/download/linux/redhat/

步骤

选择系统类型,安装配置

修改默认密码

安装配置过程中,并没有设置默认用户的密码,密码是空的

进入数据库的shell

sudo -u postgres psql

[postgresql安装完成后会自动创建一个postgres的用户]

输入\password修改密码,记住前面要加\(反斜杠)

\password postgres

postgresql的shell中,内置的命令,前面必须加反斜杠,比如退出shell

\q

而如果是sql语句,末尾必须加分号

select * from table;

如果没有加分号按回车,就是把语句保存起来,直到碰到分号,再一起执行

遇到的问题

createdb: database creation failed: ERROR: permission denied to create database

无法创建数据库,是因为没有权限

在官网文档中有描述,必须有对应的管理员权限才可以调用数据库的命令

https://www.postgresql.org/docs/11/tutorial-createdb.html

If you have a user account but it does not have the privileges required to create a database, you will see the following:

createdb: database creation failed: ERROR:  permission denied to create database

Not every user has authorization to create new databases. If PostgreSQL refuses to create databases for you then the site administrator needs to grant you permission to create databases. Consult your site administrator if this occurs. If you installed PostgreSQL yourself then you should log in for the purposes of this tutorial under the user account that you started the server as.

 

posted @   秋来叶黄  阅读(222)  评论(0编辑  收藏  举报
编辑推荐:
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
阅读排行:
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
· 葡萄城 AI 搜索升级:DeepSeek 加持,客户体验更智能
· 什么是nginx的强缓存和协商缓存
· 一文读懂知识蒸馏
点击右上角即可分享
微信分享提示