Error installing PostgreSQL via Homebrew on Mac - postgresql

When installing PostgreSQL via Homebrew on Mac (OSX 10.11.6) I get the following errors:
Error: The `brew link` step did not complete successfully The formula
built, but is not symlinked into /usr/local
and
initdb: file "/usr/local/share/postgresql/postgres.bki" does not exist
This might mean you have a corrupted installation or identified the
wrong directory with the invocation option -L.
The /postgresql folder doesn't exist.
Not sure if it's relevant, but I already have OpenSSL 1.0.2o_2 and Readline 7.0.5 installed via Homebrew.
Does anyone know why this error occurs and how I can solve it?

In my case, I had installed libpq which prevented postgresql from linking. Unlinking libpq followed by linking postgresql fixed the issue for me.
brew unlink libpq
brew link postgresql
brew postinstall postgresql

Managed to solve the problem. It's a permissions issue. The original answer can be found here: Homebrew: Could not symlink, /usr/local/bin is not writable
In short, perform the following commands:
sudo chown -R `whoami`:admin /usr/local/bin
sudo chown -R `whoami`:admin /usr/local/share
sudo chown -R `whoami`:admin /usr/local/opt

Related

Error while adding dependencies in order to install apache age

In order to install Apache age from source,
i am installing development files for PostgreSQL server-side programming. For this i am using following command on my Ubuntu OS.
sudo apt install postgresql-server-dev-11
But i am getting this error "Unable to locate package postgresql-server-dev-11"
image of the error
i am searching online but did not find yet.It would be great if someone help.
This is because you do not have the correct Ubuntu version and the package does not exist.
To determine the major PostgreSQL version in a given release of Ubuntu find it here in Ubuntu Packages
18.04 has PostgreSQL 10 (postgresql-server-dev-10)
19.04 has PostgreSQL 11 (postgresql-server-dev-11)
20.04 has PostgreSQL 12 (postgresql-server-dev-12)
If you have ubuntu 19.04 you can follow this guide
In the case there is no maintainer for the Version of PostgreSQL you are trying to install you have to build from source.
Download your PostgreSQL version source code. Then run these commands.
tar xf postgresql-version.tar.bz2
cd postgresql-version
Install dependencies. Then run the following.
./configure
make
su
make install
adduser postgres
mkdir -p /usr/local/pgsql/data
chown postgres /usr/local/pgsql/data
su - postgres
/usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data
/usr/local/pgsql/bin/pg_ctl -D /usr/local/pgsql/data -l logfile start
/usr/local/pgsql/bin/createdb test
/usr/local/pgsql/bin/psql test
Reference from Official Docs
Seems the package is not available from your package manager. But, since you want development files, it's best to get the source code directly from GitHub.
In your home directory do:
git clone https://github.com/postgres/postgres.git
cd postgres
git checkout "REL_11_STABLE"
then follow this guide https://www.thegeekstuff.com/2009/04/linux-postgresql-install-and-configure-from-source/
Official documentation for installing from source is here https://www.postgresql.org/docs/current/installation.html
You should follow these steps:
sudo apt-get update
sudo apt-get -y install postgresql-12 postgresql-client-12
sudo systemctl status postgresql
I was also facing the same problem and i just updated my Ubunutu and the error got resolved when i run the command again
I faced the same issue on Ubuntu jammy(22.04 LTS).
If you are on the same version of Ubuntu as me, try using
sudo apt install postgresql-server-dev-all
Because neither
sudo apt install postgresql-server-dev-12
nor
sudo apt install postgresql-server-dev-11
worked for me.

Mac OS - Failed to install mongodb with Homebrew due to Permission Issue

I followed the official guide to install mongodb but failed many times.
Firstly, I tried to use brew install mongodb
brew --version
Homebrew 1.4.3
brew install mongodb
Error:
Error: Permission denied # rb_sysopen - /usr/local/var/homebrew/locks/scons.formula.lock
I tried to use sudo
sudo brew install mongodb
Error:
Error: Running Homebrew as root is extremely dangerous and no longer supported.
As Homebrew does not drop privileges on installation you would be giving all
build scripts full access to your system.
I am still trying to download the binaries and extracted through the tar command, but it is more complicated and I encountered many other problems. So I hope to solve this problem firstly... Any ideas? Thanks a lot.
sudo chown -R $USER:admin /usr/local
Update:
Whilst the above solves your issue just fine, there is a much nicer way.
# allow admins to manage homebrew's local install directory
chgrp -R admin /usr/local
chmod -R g+w /usr/local
# allow admins to homebrew's local cache of formulae and source files
chgrp -R admin /Library/Caches/Homebrew
chmod -R g+w /Library/Caches/Homebrew
# if you are using cask then allow admins to manager cask install too
chgrp -R admin /opt/homebrew-cask
chmod -R g+w /opt/homebrew-cask
source: https://gist.github.com/jaibeee/9a4ea6aa9d428bc77925
I got stuck in a bit of a loop with permissions issues. I eventually uninstalled and reinstalled Homebrew and it worked for me. Here's a reference: https://github.com/Homebrew/install

homebrew nowhere to be found

I am trying to install homebrew using the command:
ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"
When I do this I get.
It appears Homebrew is already installed. If your intent is to
reinstall you should do the following before running this installer
again:
rm -rf /usr/local/Cellar /usr/local/.git && brew cleanup
So I run a
which brew
and I get nothing, just a new line.
I don't want to delete my usr/local.git because there is a lot in my directory. and the
/usr/local/Cellar Doesn't exist and when I cd into /usr/local there is no brew to be found... Which is due to the simlink I'm sure.
Anytime I run a Brew command of some sort I get
brew: command not found
I can't figure out what I am missing here. Any clues? I have search for over an hour and can't find any trace of it, even though the install says it does.
Thoughts?

Can not install postgres in ubuntu

I tried to install postgresql using the following command
apt-get install -t squeeze-backports postgresql-9.1 postgresql-client-9.1 postgresql-contrib-9.1
but i got the following error message.
E: Could not open lock file /var/lib/dpkg/lock - open (13: Permission denied)
E: Unable to lock the administration directory (/var/lib/dpkg/), are you root?
how to fix this?
It looks to me like you aren't running the command as root. Prefix it with "sudo".
sudo apt-get install -t squeeze-backports postgresql-9.1 postgresql-client-9.1 postgresql-contrib-9.1
per the error message:
E: Unable to lock the administration directory (/var/lib/dpkg/), are you root?
However, it looks like you don't understand the command, as you're running Ubuntu and Squeeze is a Debian dist. I think you need to go back to the basics and read the instructions:
Ubuntu help for Pg.
PostgreSQL-supplied packages of newer versions
Some other program has a lock on download operations. Have you got another terminal open or synaptic package manager or anything? Close everything and try again. You can also delete this file /var/lib/dpkg/lock if that doesnt work. Or it might be a root access issue. try running with sudo
Simple steps to install postgresql latest version (Believe me -- try these commends to install postgresql..it will works perfectly )
sudo bash -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/
precise-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
sudo apt-get update
sudo apt-get install postgresql-9.3 pgadmin3
For Open Terminal of postgres
sudo -u postgres psql postgres

Can not "brew install postgresql"

I cannot install postgresql with homebrew.
$ brew install postgresql
Error: Could not create /usr/local/Cellar
Check you have permission to write to /usr/local
I am not sure if homebrew was installed well. If you need more information, I will update this.
I created /usr/local/Cellar by myself, then could install successfully.
I find that if I get this problem with brew I just fix the permissions on the /use/local folder:
sudo chown -R $(whoami):admin /usr/local
I was getting an error while installation that not able to link postgres and /usr/local/include is not writable
Below solution worked for me :-
First create the include folder, note that this requires sudo privileges
cd /usr/local
sudo mkdir include
sudo chown -R $(whoami) $(brew --prefix)/*
brew link postgresql