如何在Mac上安装Postgres 9.4?无法找到相关细节,求指引
Hey there, I totally get it—tracking down an older PostgreSQL version like 9.4 on Mac can feel like searching for a needle in a haystack, since most official channels prioritize the latest releases these days. Let me walk you through two reliable methods to get it up and running:
Method 1: Install via Homebrew
Homebrew is a go-to for Mac package management, and even though 9.4 isn't in the default repo anymore, we can still grab it:
- First, make sure your Homebrew is up to date:
brew update - Next, check if the 9.4 tap is still available:
brew search postgresql@9.4 - If it shows up, install it directly:
brew install postgresql@9.4 - If not, you'll need to pull the historical formula from Homebrew's commit history. Head to the Homebrew Core GitHub repo, find the commit that corresponds to PostgreSQL 9.4, copy its hash, and run:
brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/<YOUR_COMMIT_HASH>/Formula/postgresql.rb - After installation, add the 9.4 binaries to your system PATH so your terminal recognizes it:
For Zsh users:echo 'export PATH="/usr/local/opt/postgresql@9.4/bin:$PATH"' >> ~/.zshrc
For Bash users:echo 'export PATH="/usr/local/opt/postgresql@9.4/bin:$PATH"' >> ~/.bash_profile - Reload your shell config to apply the change:
source ~/.zshrc(orsource ~/.bash_profilefor Bash)
Method 2: Use the Official PostgreSQL Archive DMG
The PostgreSQL project keeps old installers in their archive:
- Locate the Mac-specific DMG installer for 9.4 (it'll be named something like
postgresql-9.4.x-osx.dmg—you can find this in the official PostgreSQL archive section) - Download the DMG, open it, and follow the installation wizard. Make sure to note the default credentials (usually username
postgres, port5432, and a password you set during setup) - Once installed, the files will live in
/Library/PostgreSQL/9.4/. Add the bin directory to your PATH:echo 'export PATH="/Library/PostgreSQL/9.4/bin:$PATH"' >> ~/.zshrc(or your Bash config file) - Reload your shell config as before.
Verify the Installation
To confirm everything worked, open a new terminal window and run:psql --version
You should see output like psql (PostgreSQL) 9.4.x if the install was successful.
Start the PostgreSQL Service
- For Homebrew installs:
brew services start postgresql@9.4 - For official DMG installs:
You can either use the PostgreSQL icon in System Preferences to start the service, or run this command:pg_ctl -D /Library/PostgreSQL/9.4/data start
内容的提问来源于stack exchange,提问作者Pubudu
相关产品推荐
相关产品推荐

