centOS7 安装 postgresql-13, 及配置
warning:
这篇文章距离上次修改已过425天,其中的内容可能已经有所变动。
在CentOS 7上安装PostgreSQL 13,并进行基本配置的步骤如下:
- 添加PostgreSQL的官方Yum仓库:
sudo yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm- 清除缓存:
sudo yum clean all- 安装PostgreSQL 13:
sudo yum install -y postgresql13 postgresql13-server- 初始化数据库:
sudo /usr/pgsql-13/bin/postgresql-13-setup initdb- 启动PostgreSQL服务:
sudo systemctl enable postgresql-13
sudo systemctl start postgresql-13- 确认服务状态:
sudo systemctl status postgresql-13- 切换至postgres用户:
sudo su - postgres- 设置PostgreSQL用户密码:
psql -d postgres -c "ALTER USER postgres PASSWORD 'your_password';"- 登录到PostgreSQL:
psql -U postgres- 创建一个新用户和数据库(可选):
CREATE USER myuser WITH PASSWORD 'mypassword';
CREATE DATABASE mydb OWNER myuser;- 退出psql:
\q- 退出postgres用户:
exit以上步骤安装并配置了PostgreSQL 13,您可以根据需要创建数据库和用户。记得替换your_password和myuser, mypassword, 和mydb为您自己的密码和数据库信息。
评论已关闭