1.在控制台查找psql命令的路径
locate psql | grep /bin
找到的命令路径为:
/Library/PostgreSQL/9.4/bin/psql
如果没有locate数据库,请执行以下命令或按提示命令创建:
sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.locate.plist
2.编辑.bash_profile文件或.bashrc文件,添加命令别名
alias psql=/Library/PostgreSQL/9.4/bin/psql
3.使命令生效
source .bash_profile
重启数据库命令:
sudo -u postgres /Library/PostgreSQL/9.1/bin/pg_ctl -D/Library/PostgreSQL/9.1/data start