2 versions of pg_dump on my OSX Lion - macos

I had Postgres 9.0.x installed with homebrew, but because of lack of some modules I removed it using:
brew uninstall postgres
and installed Postgres 9.1.3 from http://www.enterprisedb.com/downloads/postgres-postgresql-downloads.
Now I've got a problem - 2 different versions on pg_dump - 9.0.5 and 9.1.3 and 9.0.5 is the default version.
Is there any way to set the 9.1.3 version as the default version of pg_dump?

So based on your additional comments, your new version of pg_dump is not in your PATH, all you need to do is to remove the old version, and symlink the new one to any directory in your PATH, for example, /usr/bin.
Like follows:
sudo ln -s /actual/new/pg_dump /usr/bin/pg_dump
Hope this helps

Valentin has the right answer, but of course, the question for Mac users is where the heck is pg_dump?
If you have version 9.2, it's: /Library/PostgreSQL/9.2/bin/pg_dump
Just copy this to /usr/bin

I was having the same error essentially.
pg_dump: server version: 9.1.3; pg_dump version: 9.0.4
I just used homebrew's upgrade feature, and it brought both the sever and pg_dump versions up to date with the latest version in homebrew (9.3 as of 9/19/13).
brew upgrade postgresql
I reran my dump statement, and it worked perfectly.
pg_dump -U postgres development > dump.sql

Related

Why do I have two versions of sqlite?

On my iMac (10.13.6, which is as far as it can be upgraded), I typed sqlite3 and it said I was running version 3.19.3.
So I tried upgrading with brew upgrade sqlite3 but it said sqlite3 3.28.0 already installed. The SQLite site says 3.28.0 is currently the most up to date version.
How come I have two different versions of SQLite? Does Brew install to a different location than the standard OSX version? And if so, how do I either use the upgraded brew version or upgrade the OSX version?
In general, homebrew installs links for all binaries it installs in /usr/local/bin. You can see that by running:
ls -l /usr/local/bin
So, you need to add that directory to your PATH:
export PATH=/usr/local/bin:$PATH
You likely want to do this in your login profile, which is probably $HOME/.profile so that it gets set every time you login.
I ended up creating alias command in the .zshrc file like so:
alias sqlite=/usr/local/opt/sqlite/bin/sqlite3
Don't know if that was the best way, though.

Mongodb installation failed with homebrew and Xcode 8.1.1

On running brew install mongodb, I get the following output:
Updating Homebrew...
mongodb: A full installation of Xcode.app 8.3.2 is required to compile this software.
Installing just the Command Line Tools is not sufficient.
Xcode can be installed from the App Store.
Error: An unsatisfied requirement failed this build.
My system is running on OSX El Capitan version 10.11.6.
Is there anyway to install mongodb without upgrading it to Mac OS Sierra and Xcode 8.3.3?
I am running OSX 10.11.6, unable to update to 10.12 because my machine is older (mid-2009 Macbook Pro). While trying to install MongoDB I ran into the error:
`mongodb: A full installation of Xcode.app 8.3.2 is required to compile
this software.
Installing just the Command Line Tools is not sufficient.
Xcode can be installed from the App Store.
Error: An unsatisfied requirement failed this build.`
I presently have XCode 8.0, which took some other kind of run-around to get anyway. So I needed a compatible MongoDB build. 3.0.6 is compatible.
To install through the command line with Homebrew:
`user$ brew search mongodb`
And receive this answer:
`==> Searching local taps...
mongodb mongodb#3.0 mongodb#3.2
mongodb#3.4 percona-server-mongodb`
Now:
`$ brew install mongodb#3.0`
OK, next I have a note to myself about creating these next directories in my root directory, but I did it in my current User (which has administrative access on the OS). These commands need to be precise and in this order:
`$ sudo mkdir -p /data/db`
(enter your OSX User password when prompted)
`$ sudo chown -R $USER /data/db`
`$ sudo chmod go+w /data/db`
This next one came from another S.O. answer: How to install earlier version of mongodb with homebrew?
`$ brew link --force mongodb#3.0`
This next command is provided after successful completion of the --force command:
`$ echo 'export PATH="/usr/local/opt/mongodb#3.0/bin:$PATH"' >>
~/.bash_profile`
Now, you can run your Mongo as a Daemon with:
`$ mongod`
It should now be listening on Port 27017, and in another terminal tab you can run $ mongo and use this tab to enter your Mongo queries and commands. Running it in another tab is important; allowing $ mongod to sit untouched and monitor traffic is necessary.
Edited: To update brew versions <> command per #user122121 comment and updated formatting.
Is there anyway to install mongodb without upgrading it to Mac OS Sierra and Xcode 8.3.3?
Unfortunately in order to install Xcode 8.3+ you are required to be on MacOS Sierra 10.12. See
Xcode compatibility requirements in Apple App Store for more information.
An alternative way is to download MongoDB Community edition through MongoDB Download Center, and then follow the Install MongoDB Community Edition on MacOS instruction.
You can download mongodb-app from github:
https://github.com/gcollazo/mongodbapp
I was able to successfully run mongodb4 with it on my machine, after brew installing failed.

Using mongodump: "mongodump: command not found"

I'm trying to get a dump of my local database and it seems I should be using:
mongodump --host localhost:3002
However, the terminal then tells me:
-bash: mongodump: command not found
Am I missing something? Or going about this the wrong way? I'm using it on Mac from the terminal.
I installed mongo (I think) using the following commands:
curl http://downloads.mongodb.org/osx/mongodb-osx-x86_64-2.4.5.tgz > mongodb.tgz
tar -zxvf mongodb.tgz
As of MongoDB 4.4 (released July 30, 2020), you may need to install mongodump separately because the MongoDB Database Tools (which comprises mongodump, mongorestore, and more) has become its own project.
I found this out because I upgraded to MongoDB 4.4 today and mongodump stopped working.
$ mongodump
zsh: command not found: mongodump
I'm on macOS and installed MongoDB via Homebrew. To get mongodump and friends back, I installed the MongoDB Database Tools via Homebrew:
brew tap mongodb/brew
brew install mongodb-database-tools
If you're on a different OS, this should help:
MongoDB Database Tools Installation
brew tap mongodb/brew; brew install mongodb-community
will also install mongodump.
If you don't have the brew command, you really should consider install Homebrew
If you just extracted the .tgz file, the mongodump command is not available in your PATH. Go to your /bin/ subdirectory inside the directory where you have extracted mongodb.tgz, the mongodump binary should be there. Now you can execute:
./mongodump --host localhost:3002
It's much better though to install MongoDB with a package manager. Read this page:
http://docs.mongodb.org/manual/tutorial/install-mongodb-on-os-x/
and use, for example, Homebrew to install MongoDB and have all the necessary binaries in PATH.
brew tap mongodb/brew
brew install mongodb-database-tools
For using mongodump, mongo-tools library has to be installed from os package manager.
It's probably just not in your path, it should be in the same directory as your "mongod", and you can then run it with:
/path/to/bin/mongodump --host localhost:3002
It's in the official MongoDB docs now. For example, to install the 3.2 version:
brew tap mongodb/brew
brew install mongodb-community#3.2
Then follow the steps to update your PATH environment variable.
You have to install mongo-tools to have mongodump.
sudo apt-get install mongo-tools
For Windows Users
You can download the MongoDB Database Tools from here
And you can read the installation guide here

Updating Postgres from 9.1.4

I tried to run homebrew install of Postgres and it looks like it's installing 9.1.4 the same as whats con my new Mac 10.8 system. After I ran the command brew install postgresql
and ran initdb /usr/local/var/postgres -E utf8
I checked version .
psql --version
psql (PostgreSQL) 9.1.4
which psql
/usr/local/bin/psql
This looks to me like its install the same version which would be originally in /usr/bin/
I'm trying to get it to run the latest version which looks like its 9.2.2
What am I missing here.
You may want to check in /Library/PostgreSQL/ and see if this directory exists. From my understanding, Homebrew will often install PostgreSQL into that path. If this is the case you may have a newer version of PostgreSQL than what you think and setting your PATH envar will fix the problem.
If this is the case you will want to set your system to start up only one of the databases, or if it starts up both set them on different ports.

Having Trouble Using "brew link" to switch between PostgreSQLs

I want to run a Rails app on Heroku so I installed PostgreSQL on my Snow Leopard machine using Homebrew. Currently, brew installs 9.1.2 into /usr/local/Cellar/postgresql. After some research, I discovered that the free, shared version of Heroku requires 8.3.x. While homebrew-alt doesn't have 8.3, it does have 8.4 so I downloaded it instead and it installed into /usr/local/Cellar/postgresql8. I then confirmed that I am able to create and run databases on each version. Thinking that I could use "brew [link | unlink] to switch back and forth, I ran "brew unlink postgresql8" and then "brew link postgresql". However, running the latter command results in this error:
Linking /usr/local/Cellar/postgresql/9.1.2...
Error: Cannot link postgresql
Another version is already linked: /usr/local/Cellar/postgresql/9.1.2
Is there any way to do this (switch back and forth) or am I misunderstanding how brew link/unlink is supposed to be used?
By the way, "brew list" shows "postgresql" and "postgresql8" so I don't think it's the case that I should say "brew link postgresql9".
Thanks.
Use brew switch, which is an extension shipped with Homebrew. In your case, you could use 8.4 by running
$ brew switch postgresql 8.4
Thanks, mipadi! That did the trick. There was only one additional thing that I needed to do. The 'brew switch' command assumes all versions of postgresql are installed in /usr/local/Cellar/postgresql. That was not the case with version 8.4.8 as it was installed in /usr/local/Cellar/postgresql8. Consequently I had to create a symbolic link to point to this older version:
cd /usr/local/Cellar/postgresql
ln -s ../postgresql8/8.4.8 8.4.8
Naturally, it also makes sense to keep your database clusters in separate directories:
/usr/local/var/postgres/8.4.8
/usr/local/var/postgres/9.1.2

Resources