PostgreSQL在Linux环境下安装
    		       		warning:
    		            这篇文章距离上次修改已过423天,其中的内容可能已经有所变动。
    		        
        		                
                在Linux环境下安装PostgreSQL,可以通过包管理器或者从源代码编译安装。以下是两种常见的安装方法:
通过包管理器安装(以Ubuntu为例)
- 更新包列表:
sudo apt update- 安装PostgreSQL:
sudo apt install postgresql postgresql-contrib- 启动PostgreSQL服务:
sudo systemctl start postgresql- 确保PostgreSQL随系统启动:
sudo systemctl enable postgresql- 切换到PostgreSQL用户:
sudo -i -u postgres- 创建一个新的角色(可选):
createuser --interactive- 创建一个新数据库(可选):
createdb <your_database_name>从源代码编译安装
- 安装编译依赖:
sudo apt install build-essential- 下载PostgreSQL源代码:
wget https://ftp.postgresql.org/pub/source/v12.3/postgresql-12.3.tar.gz- 解压源代码:
tar -xzvf postgresql-12.3.tar.gz- 进入解压后的目录:
cd postgresql-12.3- 配置安装选项:
./configure- 编译和安装:
make
sudo make install- 初始化数据库:
sudo /usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data- 启动PostgreSQL服务:
sudo /usr/local/pgsql/bin/pg_ctl -D /usr/local/pgsql/data -l logfile start请根据你的Linux发行版和PostgreSQL版本选择合适的安装方法,并确保所有步骤都按照你的系统权限执行。
评论已关闭