Created
August 25, 2017 22:27
-
-
Save AlexeyLevin/3fc1edd97ca2378c449b7d7d29f117fd to your computer and use it in GitHub Desktop.
pg up
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
| Download Postgresql binary file: | |
| http://www.enterprisedb.com/products-services-training/pgbindownload | |
| Version: 9.4.4 | |
| Setup Postgresql (One time setup): | |
| For Windows: | |
| Download postgresql-*-binaries.zip file from the download link | |
| Extract the zip file | |
| Set environment variable PG_HOME as the parent folder of bin | |
| Add %PG_HOME%\bin to PATH environment variable | |
| Create two folders namely ‘data’ and ‘log’ under %PG_HOME% | |
| Open a command prompt | |
| Go to %PG_HOME% | |
| Execute: initdb -U postgres -A password -E utf8 -W -D data | |
| Enter a password (and remember it)and finish setup | |
| Note: | |
| If you get error message like ‘MSVCR120.dll is missing from your computer. Try reinstalling the program to fix this problem.’, then Microsoft Visual C++ Redistributable Packages for Visual Studio from http://www.microsoft.com/en-us/download/details.aspx?id=40784 | |
| Choose the appropriate vcredist_*.exe for your computer. | |
| For Ubuntu: | |
| Download postgresql-*-binaries.tar.gz file from the download link | |
| Extract the file | |
| Set environment variable PG_HOME as the parent folder of bin | |
| Add $PG_HOME/bin to PATH environment variable | |
| Create two folders namely ‘data’ and ‘log’ under $PG_HOME | |
| Open a terminal | |
| Execute: initdb -U postgres -A password -E utf8 -W -D $PG_HOME/data | |
| Enter a password (and remember it)and finish setup | |
| Start Postgresql: | |
| For Windows: | |
| Open command prompt | |
| Go to %PG_HOME% | |
| Execute:pg_ctl -D "data" -l "log/pgsql.log" -o "-p 5432" start | |
| For Ubuntu: | |
| Open a terminal | |
| Execute:pg_ctl -D "$PG_HOME/data" -l "$PG_HOME/log/pgsql.log" -o "-p 5432" start | |
| Stop Postgresql: | |
| For Windows: | |
| Open command prompt | |
| Go to %PG_HOME% | |
| Execute:pg_ctl -D "data" -l "log/pgsql.log" stop | |
| For Ubuntu: | |
| Open a terminal | |
| Execute:pg_ctl -D "$PG_HOME/data" -l "$PG_HOME/log/pgsql.log" stop | |
| Connect to Postgresql: | |
| For Windows: | |
| Execute: | |
| psql --username=postgres | |
| or | |
| psql --username=postgres --dbname=postgres --host=localhost --port=5432 | |
| Type \q to quit | |
| For Ubuntu: | |
| Execute: | |
| psql --username=postgres | |
| or | |
| psql --username=postgres --dbname=postgres --host=localhost --port=5432 | |
| Type \q to quit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment