export PATH="/Applications/Postgres.app/Contents/Versions/9.4/bin:$PATH"
to .bash_profilegem install pg -- --with-pg-config=/Applications/Postgres.app/Contents/Versions/latest/bin/pg_config
brew install postgresql
brew services start postgresql
brew services list
psql
If you can’t connect, check the output of brew services list, look at the .plist file, check the ProgramArguments, run that command, and see the error it gives you
createuser shawsome
createdb -Oshawsome shawsome_development
createdb -Oshawsome shawsome_test
ALTER USER "myuser" WITH SUPERUSER; -- to create databases
ALTER USER "myuser" WITH PASSWORD 'mypassword';
(for some reason the double vs single quotes matter)
http://blog.willj.net/2011/05/31/setting-up-postgresql-for-ruby-on-rails-development-on-os-x/
\du - list users \l - list databases \connect mydbname - switch to db \dt - list tables \q - quit
psql -h host -p port -U username -d database pg_dump dbname > outfile psql dbname < outfile
Run as postgres user on Ubuntu:
sudo -i -u postgres [psql or pg_dump etc]
Seems to not be granted by default
sudo service postgresql stop
sudo su - postgres
ALTER USER postgres WITH SUPERUSER;
select usesuper from pg_user where usename = CURRENT_USER;
sudo service postgresql start
ALTER USER postgres WITH NOSUPERUSER;