-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpostgres.sh
52 lines (33 loc) · 1.01 KB
/
postgres.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# MAC
# Install
brew install postgresql
# Manage
brew services start postgresql
brew services restart postgresql
brew services stop postgresql
# List all brew services
brew services list
# List all databases on your device
psql --list
# ---------
# DEBIAN
# First always switch to the postgres user:
sudo -i -u postgres
# Then you can run commands like:
psql --list
# ---------
# TROUBLE SHOOTING
# PG::ConnectionBad`
# EADDRINUSE
# Check if Postgres is running.
# Port 3000 is already taken by another process. This is most likely a rogue Puma
# process that wasn't stopped properly. Find the process ID (pid) by running:
sudo lsof -iTCP -sTCP:LISTEN -P
# Then kill the one listening to port 3000
kill -9 [pid]
# PG::ConnectionBad (could not connect to server: Connection refused
# Is the server running on host "localhost" (::1) and accepting
# TCP/IP connections on port 5432?
rm /usr/local/var/postgres/postmaster.pid
# In case you've upgraded Postgres, first migrate the database:
brew postgresql-upgrade-database