Last active
December 14, 2015 18:19
-
-
Save ktkaushik/5128402 to your computer and use it in GitHub Desktop.
Installing postgresql on mac (mountain lion, if that matters)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # install Homebrew (figure it out yourself) | |
| #use brew to install postgresql | |
| brew install postgresql | |
| # Next, try and run the executable for postgresql command | |
| psql | |
| # If you get an error saying 'command not found' then that means that your executable path has not been set to your terminal. | |
| # In ubuntu, you might need to edit bashrc file but in Mac its ~/.bash_profile wherein you set the path of the executable | |
| # Once you have installed postgresql using Homebrew, the executable has also been setup in the Postgresql installed folder. One way is to browse through the folder | |
| # the other is to use the 'find' command in terminal | |
| sudo find / -name psql | |
| # Add the path to the bash_profile | |
| export PATH="/usr/local/bin:/usr/local/sbin:/usr/local/Cellar/postgresql/9.2.3/bin/:~/bin:$PATH" | |
| # now you gotta run the initdb command | |
| initdb /usr/local/var/postgres -E utf8 | |
| # There are chances that you might run into Shared segment errors for lack of memory. In that case, you can edit /etc/sysctl.conf file. | |
| # Change it to this. (if the file does not exist, then create one) | |
| kern.sysv.shmmax=1610612736 | |
| kern.sysv.shmmin=1 | |
| kern.sysv.shmmni=256 | |
| kern.sysv.shmseg=64 | |
| kern.sysv.shmall=393216 | |
| # Save and reboot and run the initdb command again | |
| # Open the terminal again and try and run psql command | |
| psql | |
| # if you get an error like this : | |
| database your-username does not exist | |
| # then try this | |
| psql -d postgres | |
| # Once you are in psql shell, create a database by your username | |
| create database your-username; | |
| # Now quit | |
| \q | |
| # Now try installing pg gem | |
| gem install pg | |
| # if you create a database with rake db:create command then chances are you might get this error | |
| Library not loaded: /usr/local/opt/postgresql/lib/libpq.5.5.dylib | |
| # So just find the libpq.5.5.dylib | |
| sudo find / -name libpq.5.5.dylib | |
| # copy the location of the file (it has to be present somewhere for sure) | |
| # now just create a symlink for the libpq.5.5.dylib for the location that rails desires | |
| sudo ln -s rails/desired/location location/of/libpq.5.5.dylib | |
| # Do not forget to install instrumentation for pgAdmin | |
| psql -d postgres < /usr/local/Cellar/postgresql/9.0.1/share/contrib/adminpack.sql | |
| # 9.2.3 the location has changed to | |
| psql -d postgres < /usr/local/Cellar/postgresql/9.2.3/share/postgresql/extension/adminpack--1.0.sql | |
| # thats about it !! | |
| # this should work | |
| # REf | |
| # http://rails3hub.blogspot.in/2012/02/install-postgresql-9-on-os-x.html (Read the comments too) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment