getting ddev and drush site install to work for multisite install - drush

I am trying to create a new drupal 7 multisite from my ddev web container. While drush si runs fine, creating another db and site fails.
I run ddev ssh from the host and then issue a
drush site-install --sites-subdir=mysite --db-url=mysql://db:db#db/mysite --db-su=root --db-su-pw=root
This doesn't seem to work.
While just entering the mysql-db as root with mysql -uroot -h db
and creating the new database works.
Running drush with --debug option shows, that the user db can not access the DB:
sql-query: DROP DATABASE IF EXISTS test8; CREATE DATABASE test8 /*!40100 DEFAULT CHARACTER SET utf8 */; GRANT ALL PRIVILEGES ON test8.* TO 'db'#'%' IDENTIFIED BY 'db'; FLUSH PRIVILEGES; [4.26 sec, 2.03 MB] [notice]
Executing: mysql --defaults-extra-file=/tmp/drush_lGzF0v --database=information_schema --host=db --silent < /tmp/drush_GTSajV
ERROR 1044 (42000) at line 1: Access denied for user 'db'#'%' to database 'test8'
Failed to create database: ERROR 1044 (42000) at line 1: Access denied for user 'db'#'%' to database 'test8' [4.3 sec, 2.03 MB]
Workaround
add the Grant like said in the comment below:
grant all on *.* to 'db'#'%';
and if I now run the same drush command twice in a row it works and installs the site.
I haven't tried this on a different stack, so maybe it is a bug in drush site-install.
I did the same for drupal 8 on ddev too and it shows similar behavior, even if it produces different errors. The same workaround, running the command twice fixes the site install.

Related

Neo4j - unable to get routing for database neo4j - unavailable after system upgrade

I have been running a neo4j database for a while without problem.
Yesterday our server OS was update from centos-8 to centos-stream, and since this upgrade our neo4j database does not start anymore.
The service is listed as running but on every query it says: Unable to get a routing table for database 'neo4j' because this database is unavailable.
I cannot log in to the cypher shell because it shuts down with the same error.
I'm not sure what I can do here, I would like to not reset the database as we need the information in there.
The versions I'm running are as follows:
neo4j-4.3.6-1.noarch
neo4j-java11-adapter-1-1.noarch
I had similar issue, so I checked the logs and found the below error in the logs.
Caused by: java.nio.file.AccessDeniedException:
/var/lib/neo4j/data/databases/neo4j/neostore
The fix for the above issue is to change the ownership of noe4j databases folders and files.
cd /var/lib/neo4j/data
sudo chown -R neo4j:neo4j databases/
sudo chown -R neo4j:neo4j transactions/
Restart the neo4j service
sudo systemctl restart neo4j.service

ThingsBoard installation failed! On Ubuntu

I am trying to install thingsboard PE instance on Ubuntu 18.04.3 LTS
while I run this command
sudo /usr/share/thingsboard/bin/install/install.sh --loadDemo
I am facing the following error
Error: Could not find or load main class org.springframework.boot.loader.PropertiesLauncher
ThingsBoard installation failed!
the thingsboard.log file is not present in /var/log/thingsboard
Can anyone please suggest me what's the reason for this error?
Make sure the thingsboard database does actually exist. I had the same error. I did follow the instructions, but possibly the CREATE DATABASE was not followed by ';' or it needed to be started.
Restart the ubuntu server.
Log in and log onto PSQL: psql -U postgres -d postgres -h 127.0.0.1 -W
Check for existence of the database: \list
If it does not exists, run: CREATE DATABASE thingsboard;
Run \list again and make sure it exists. Quit by running \q.
Re-run the demo create script: sudo /usr/share/thingsboard/bin/install/install.sh --loadDemo
Happy Thing-ing.
Along with the above as Antony Horne has suggested, also you can remove the ThingsBoard related directories under /tmp/. Remove and recreate the 'thingsboard' database. Make sure to set the password as 'postgres'. Then re-run the command
/usr/share/thingsboard/bin/install/install.sh --loadDemo
It should be fine.
Though after that, when I tried to run the 'thingsboard' as
service thingsboard start
Its is not working as 'thingsboard' is unrecognized. Couldn't solve that yet.

Ruby on Rails project with Postgres DB, created on Macbook, need to access on windows 10

A while ago I created a Ruby on Rails project with a postgres database. It was originally created on a macbook where I had set up a working production and test environment. Unfortunately, this computer has died and now I have to continue working on the same project using the only machine I have: a Windows 10 laptop.
I have been following these guides to set up a viable rails environment on my windows 10 pc:
https://medium.com/#colinrubbert/installing-ruby-on-rails-in-windows-10-w-bash-postgresql-e48e55954fbf
https://gorails.com/setup/windows/10
I have installed bash/ubuntu successfully. I have installed git successfully. I have installed ruby successfully. I have installed all the pre-requisite gems so that I can run bundle install successfully. When I get to postgres, as suggested by both tutorials, I install it via windows instead of installing it by terminal. With Postgres 9.6 installed and running as a windows service, I'm unable to enter psql in the terminal. I get this error:
psql: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
Additionally, here are the errors that appear when I attempt to do something with rake db commands:
FATAL: role "xxx" does not exist
Couldn't create database for {"adapter"=>"postgresql", "encoding"=>"unicode", "pool"=>5, "database"=>"YelpClone_development", "host"=>"localhost"}
rake aborted!
ActiveRecord::NoDatabaseError: FATAL: role "xxx" does not exist
'xxx' above is my username. I'm not sure if its the username from my old mac or on my new windows machine. I've attempted to edit the database.yml inside my rails project but that gets the same results.
Looking at this topic about the role error, I attempted to use the command "sudo -u postgres -i" which results in another error:
sudo: setresuid() [1000, 112, 1000] -> [-1, 0, -1]: Operation not permitted
sudo: unable to set runas group vector: Operation not permitted
sudo: unable to mkdir /var/run/sudo: Permission denied
[sudo] password for xxx:
sudo: PERM_ROOT: setresuid(0, -1, 0): Operation not permitted
xxx is not in the sudoers file. This incident will be reported.
Once again 'xxx' is my username. Now I'm beginning to suspect that all this stuff did NOT install correctly. But I'm unsure how I can check. I've tried re-installing postgres about 5-6 times now. Can anyone shed some light on this mess?
I have found a solution to this problem and I thought I would post how I solved it in case anyone else had the same issues:
I followed the instructions found on this page for issues specific to the WSL (Windows subsystem for Linux), specifically posted by user leafofLegend.
The main problem I had was getting stuck on step 7. I had to downgrade my postgres install to 9.3 in order to have PGAdmin 3 instead of 4 as it no longer has editing features for server config. The 2nd issue was being unable to access the ~/.bashrc file. I attempted to open it in atom (via terminal) but it would show me a blank file each time. Alternatively, if I navigated to the file on windows and opened it there, it would become corrupted and not source to the terminal properly. You CANNOT edit linux files using windows tools. Therefore I had to use nano editor to edit the ~./bashrc file as stated in step 9.
The above steps solved the bulk of the problem, which was getting a windows installed PG to be friendly with a WSL terminal. Following the rest of the steps, I'm now able to run rake DB commands and create new dbs.

dropdb: database removal failed: ERROR: checkpoint request failed

I only know the basics of using postgres db and have been using it for about a year without any major problems I couldn't get through with the docs or existing stackoverflow questions.
But now I have a problem where I keep getting the following error on my pg db on my mac. I tried to install an updated postgres using brew which installed successful, but I think in the process I created another problem. The error is when trying to start the db:
LOG: database system shutdown was interrupted; last known up at 2015-10-04 11:04:08 EDT
LOG: database system was not properly shut down; automatic recovery in progress
LOG: redo starts at 0/6000090
LOG: record with zero length at 0/6001990
LOG: redo done at 0/6001960
LOG: last completed transaction was at log time 2015-10-04 10:56:33.121103-04
FATAL: could not open directory "pg_logical/snapshots": No such file or directory
LOG: startup process (PID 12905) exited with exit code 1
LOG: aborting startup due to startup process failure
So I followed the instructions here for using pg_resetxlog and then procceeded to try and "REINDEX, dump your database(s), re-initdb, and reload your databases" Per pg documentation for 9.4 with no successful results. Im just going in circles.
I can start over with the db but I'm unable to drop it and start over. If I run dropdb dbname I get
dropdb: could not connect to database template1: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
But I can't start the db because after running
pg_resetxlog -f /usr/local/var/postgres
And getting back "Transaction log reset" I run
pg_ctl start -D /usr/local/var/postgres
And get
pg_ctl: another server might be running; trying to start server anyway
server starting
FATAL: lock file "postmaster.pid" already exists
HINT: Is another postmaster (PID 13114) running in data directory "/usr/local/var/postgres"?
So I ran
ps auxwww | grep postgres
And got
Travis 13127 0.0 0.0 2432772 660 s000 S+ 11:24AM 0:00.00 grep postgres
Travis 13120 0.0 0.0 2468112 604 ?? Ss 11:21AM 0:00.00 postgres: stats collector process
Travis 13119 0.0 0.0 2604776 1444 ?? Ss 11:21AM 0:00.00 postgres: autovacuum launcher process
Travis 13118 0.0 0.0 2604776 732 ?? Ss 11:21AM 0:00.00 postgres: wal writer process
Travis 13117 0.0 0.0 2612968 1776 ?? Ss 11:21AM 0:00.05 postgres: writer process
Travis 13116 0.0 0.0 2604776 756 ?? Ss 11:21AM 0:00.00 postgres: checkpointer process
Travis 13114 0.0 0.2 2604776 14576 ?? S 11:21AM 0:00.02 /usr/local/opt/postgresql/bin/postgres -D /usr/local/var/postgres -r /usr/local/var/postgres/server.log
So I ran
kill 13114
Then
ps auxwww | grep postgres
And got
Travis 13139 0.0 0.0 2432772 652 s000 S+ 11:25AM 0:00.00 grep postgres
Of course at this point if I try to start the db again I go in the same circle.
Now if I run
pg_resetxlog -f /usr/local/var/postgres
followed by
psql template1
And try to drop the db nothing happens.
It's a db for a rails project. So if I run
rake db:drop
I get another
PG::InternalError: ERROR: checkpoint request failed
It also says there is a hint in the server log which I checked with
live:
tail -f /usr/local/var/postgres/server.log
Or:
tail /usr/local/var/postgres/server.log
And get
ERROR: could not open directory "pg_logical/snapshots": No such file or directory
ERROR: could not open directory "pg_logical/snapshots": No such file or directory
ERROR: could not open directory "pg_logical/snapshots": No such file or directory
ERROR: could not open directory "pg_logical/snapshots": No such file or directory
ERROR: could not open directory "pg_logical/snapshots": No such file or directory
ERROR: could not open directory "pg_logical/snapshots": No such file or directory
ERROR: could not open directory "pg_logical/snapshots": No such file or directory
ERROR: could not open directory "pg_logical/snapshots": No such file or directory
ERROR: could not open directory "pg_logical/snapshots": No such file or directory
ERROR: could not open directory "pg_logical/snapshots": No such file or directory
I'm not sure how to fix that or why it dosent exist anymore in the first place. Search results returned this but there was no solution showing the full path for manually creating the directory
At this point I'm so confused I think I'm making things worse.
I checked other db on my system and see I have the same problem for all databases on my machine now. Plus I always have 1 grep postgres pid running that i can't stop with kill 13498 or by restarting my mac.
How do i fix this without loosing all databases on my machine?
Brew info postgres shows:
postgresql: stable 9.4.4 (bottled), devel 9.5alpha2
Object-relational database system
https://www.postgresql.org/
Conflicts with: postgres-xc
/usr/local/Cellar/postgresql/9.4.1_1 (2996 files, 40M)
Poured from bottle
/usr/local/Cellar/postgresql/9.4.4 (3014 files, 40M) *
Poured from bottle
From: https://github.com/Homebrew/homebrew/blob/master/Library/Formula/postgresql.rb
==> Dependencies
Required: openssl ✔, readline ✔
==> Options
--32-bit
Build 32-bit only
--with-dtrace
Build with DTrace support
--with-python
Build with python support
--without-perl
Build without Perl support
--without-tcl
Build without Tcl support
--devel
Install development version 9.5alpha2
==> Caveats
If builds of PostgreSQL 9 are failing and you have version 8.x installed,
you may need to remove the previous version first. See:
https://github.com/Homebrew/homebrew/issues/2510
To migrate existing data from a previous major version (pre-9.4) of PostgreSQL, see:
https://www.postgresql.org/docs/9.4/static/upgrading.html
To have launchd start postgresql at login:
ln -sfv /usr/local/opt/postgresql/*.plist ~/Library/LaunchAgents
Then to load postgresql now:
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
Or, if you don't want/need launchctl, you can just run:
postgres -D /usr/local/var/postgres
I'm running yosemite 10.10.5
After a few more hours of research I got things working again without loosing any of my databases.
From my other mac I found where the directory should be created that the user referenced in this post that needed to be created. I also created the other two missing directories:
mkdir /usr/local/var/postgres/pg_logical
mkdir /usr/local/var/postgres/pg_logical/mappings
mkdir /usr/local/var/postgres/pg_logical/snapshots
Next I ran the following for good measure
brew update
and
brew doctor
Then I installed brew services (info docs and article )
brew tap homebrew/services
Next i ran the following which i derived from hints here because in the process of troubleshooting/trial and error the "pg_resetxlog -f /usr/local/var/postgres" command started throwing errors.
brew services stop postgresql
Then I tried my usual
pg_ctl -D /usr/local/var/postgres start
And everything started working normally. Since brew services is installed now I can start the db with:
brew services start postgresql
I'm still not sure why restarting my mac didn't help after creating the directories. And I'm also not sure why/how/when those directories were removed. And I'm not sure what really created the problems to start with. But after doing what I've listed, everything is working.
Hi I have faced below error while deleting the database:
Error: checkpoint request failed
Need to restart the database and you can try to delete database.
sucessfully delete database.
If the disk space is full, you will not be able to drop any database and you will consistently get the 'Error: checkpoint request failed' message.
To manually delete the database follow these steps:
1. Shutdown Postgres (note that Postgres won't restart until you free up disk space)
2. Delete the database data directory (dddd) in /var/lib/postgresql/9.x/main/base/dddd
3. Restart Postgres (it should restart now that you have freed up space)
4. Execute 'drop database db_name' through psql console (to finish the cleanup)

Can not connect to local PostgreSQL

I've managed to bork my local development environment.
All my local Rails apps are now giving the error:
PGError
could not connect to server: Permission denied
Is the server running locally and accepting
connections on Unix domain socket "/var/pgsql_socket/.s.PGSQL.5432"?
I've no idea what's caused this.
While searching for a solution I've updated all bundled gems, updated system gems, updated MacPorts. No joy.
Others have reported this issue when upgrading from OSX Leopard to Lion, due to confusion over which version of Postgres should be used (i.e., OSX version or MacPorts version). I've been running Lion for several months, so it seems strange that this should happen now.
I'm reluctant to mess around too much without first understanding what the problem is. How can I debug this methodically?
How can I determine how many versions of PostgreSQL are on my system, which one is being accessed, and where it is located? How do I fix this if the wrong PostgreSQL is being used?
Sorry for the noob questions. I'm still learning how this works! Thanks for any pointers.
EDIT
Some updates based on suggestions and comments below.
I tried to run pg_lsclusters which returned a command not found error.
I then tried to local my pg_hba.conf file and found these three sample files:
/opt/local/share/postgresql84/pg_hba.conf.sample
/opt/local/var/macports/software/postgresql84/8.4.7_0/opt/local/share/postgresql84/pg_hba.conf.sample
/usr/share/postgresql/pg_hba.conf.sample
So I assume 3 versions of PSQL are installed? Macports, OSX default and ???.
I then did a search for the launchctl startup script ps -ef | grep postgres which returned
0 56 1 0 11:41AM ?? 0:00.02 /opt/local/bin/daemondo --label=postgresql84-server --start-cmd /opt/local/etc/LaunchDaemons/org.macports.postgresql84-server/postgresql84-server.wrapper start ; --stop-cmd /opt/local/etc/LaunchDaemons/org.macports.postgresql84-server/postgresql84-server.wrapper stop ; --restart-cmd /opt/local/etc/LaunchDaemons/org.macports.postgresql84-server/postgresql84-server.wrapper restart ; --pid=none
500 372 1 0 11:42AM ?? 0:00.17 /opt/local/lib/postgresql84/bin/postgres -D /opt/local/var/db/postgresql84/defaultdb
500 766 372 0 11:43AM ?? 0:00.37 postgres: writer process
500 767 372 0 11:43AM ?? 0:00.24 postgres: wal writer process
500 768 372 0 11:43AM ?? 0:00.16 postgres: autovacuum launcher process
500 769 372 0 11:43AM ?? 0:00.08 postgres: stats collector process
501 4497 1016 0 12:36PM ttys000 0:00.00 grep postgres
I've posted the contents of postgresql84-server.wrapper at http://pastebin.com/Gj5TpP62.
I tried to run port load postgresql184-server but received an error Error: Port postgresql184-server not found.
I'm still very confused how to fix this, and appreciate any "for dummies" pointers.
Thanks!
EDIT2
This issue began after I had some problems with daemondo. My local Rails apps were crashing with an application error along the lines of "daemondo gem can not be found". I then went through a series of bundle updates, gem updates, port updates and brew updates to try and find the issue.
Could this error be an issue with daemondo?
This really looks like a file permissions error. Unix domain sockets are files and have user permissions just like any other. It looks as though the OSX user attempting to access the database does not have file permissions to access the socket file. To confirm this I've done some tests on Ubuntu and psql to try to generate the same error (included below).
You need to check the permissions on the socket file and its directories /var and /var/pgsql_socket. Your Rails app (OSX user) must have execute (x) permissions on these directories (preferably grant everyone permissions) and the socket should have full permissions (wrx). You can use ls -lAd <file> to check these, and if any of them are a symlink you need to check the file or dir the link points to.
You can change the permissions on the dir for youself, but the socket is configured by postgres in postgresql.conf. This can be found in the same directory as pg_hba.conf (You'll have to figure out which one). Once you've set the permissions you will need to restart postgresql.
# postgresql.conf should contain...
unix_socket_directory = '/var/run/postgresql' # dont worry if yours is different
#unix_socket_group = '' # default is fine here
#unix_socket_permissions = 0777 # check this one and uncomment if necessary.
EDIT:
I've done a quick search on google which you may wish to look into to see if it is relavent.
This might well result in any attempt to find your config file failing.
http://www.postgresqlformac.com/server/howto_edit_postgresql_confi.html
Error messages:
User not found in pg_hba.conf
psql: FATAL: no pg_hba.conf entry for host "[local]", user "couling", database "main", SSL off
User failed password auth:
psql: FATAL: password authentication failed for user "couling"
Missing unix socket file:
psql: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
Unix socket exists, but server not listening to it.
psql: could not connect to server: Connection refused
Is the server running locally and accepting
connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
Bad file permissions on unix socket file:
psql: could not connect to server: Permission denied
Is the server running locally and accepting
connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
My gut feeling is that this is (again) a mac/OSX-thing: the front end and the back end assume a different location for the unix-domain socket (which functions as a rendezvous point).
Checklist:
Is postgres running: ps aux | grep postgres | grep -v grep should do the trick
Where is the socket located: find / -name .s.PGSQL.5432 -ls (the socket used to be in /tmp; you could start looking there)
even if you locate the (unix-domain) socket, the client could use a different location. (this happens if you mix distributions, or of you have a distribution installed someplace and have another (eg from source) installation elsewhere), with client and server using different rendez-vous addresses.
If postgres is running, and the socket actually exists, you could use:
psql -h /the/directory/where/the/socket/was/found mydbname
(which attempts to connect to the unix-domain socket)
; you should now get the psql prompt: try \d and then \q to quit. You could also
try:
psql -h localhost mydbname.
(which attempts to connect to localhost (127.0.0.1)
If these attempts fail because of insufficient authorisation, you could alter pg_hba.conf (and SIGHUP or restart) In this case: also check the logs.
A similar question: Can't get Postgres started
Note: If you can get to the psql prompt, the quick fix to this problem is just to change your config/database.yml, add:
host: localhost
or you could try adding:
host: /the/directory/where/the/socket/was/found
In my case, host: /tmp
Try uninstalling the pg gem (gem uninstall pg) then reinstalling -- if you use bundler, then bundle install, else gem install pg. Also, make sure path picks up the right version: Lion has a version of posgresql (prior versions didn't) and it may be in the path before your locally installed version (e.g. MacPorts, homebrew).
In my case: homebrew install of postgresql, updated postgresql, rails, etc. and then got this error. Uninstalling and reinstalling the pg gem did it for me.
The location of the socket file is baked into the gem at compile time. Thus you need to rebuild your pg gem.
gem pristine pg
# or
bundle exec gem pristine pg
This should resolve that particular issue.
If you're getting a similar error:
psql: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
This might do the trick (it did for me):
initdb /usr/local/var/postgres -E utf8
The directory specified should be different if you're not using OSX/Brew.
Note: This is not the exact error message seen above, but this thread is the first result for that error message.
what resolved this error for me was deleting a file called postmaster.pid in the postgres directory. please see my question/answer using the following link for step by step instructions. my issue was not related to file permissions:
psql: could not connect to server: No such file or directory (Mac OS X)
the people answering this question dropped a lot of game though, thanks for that! i upvoted all i could
This is how I solved that error message, based partly on wildplasser's answer.
find / -name .s.PGSQL.5432 -ls 2> /dev/null
=> ... /tmp/.s.PGSQL.5432
So, there's my socket or whatever, but the client looks for it at:
/var/run/postgresql/.s.PGSQL.5432
So quite simply make a symbolic link to the /tmp/.s.PGSQL.5432:
sudo ln -s /tmp/.s.PGSQL.5432 /var/run/postgresql/.s.PGSQL.5432
Hope this helps to anyone. The seems kind of wrong, but hey, it works!
I started getting this after upgrading to a new postgres - I didn't realize I had hold data files.
First I tried to start the postgres server:
postgres -D /usr/local/var/postgres
which is how I saw this error
FATAL: database files are incompatible with server
DETAIL: The data directory was initialized by PostgreSQL version 9.0, which is not compatible with this version 9.3.5.
So then I found this answer on SO - related to an incompatibility error: https://serverfault.com/questions/342626/how-do-i-upgrade-postgresl-database-incompatibility-error
This is what fixed it
mv /usr/local/var/postgres /usr/local/var/postgres.old
initdb -D /usr/local/var/postgres
Just confirming I had a similar issue on PSQL and Django,
Looked like because my psql server was not shut down correctly and the postmaster.pid file was still present (should be deleted on proper shutdown automatically) in my postgres folder.
Deleted this and all good
I was getting this same error (it turns out it was an error with postmaster.pid. Here's how I got postgres up and running again (credit to Ricardo Burillo for the fix):
$ rm /usr/local/var/postgres/postmaster.pid
$ pg_resetxlog -f /usr/local/var/postgres
I had similar problem when trying to use postgresql with rails. Updating my Gemfile to use new version of gem pg solve this problem for me. (gem pg version 0.16.0 works). In the Gemfile use:
gem 'pg', '0.16.0'
then run the following to update the gem
bundle install --without production
bundle update
bundle install
This happened to me today after my Macbook's battery died. I think this can be caused by improper shutdown. All you have to do in cases such as mine is delete postmaster.pid
Navigate to the folder
cd /usr/local/var/postgres
Check to see if postmaster.pid is present
ls
Remove postmaster.pid
rm postmaster.pid
I read many topics about this error and the solution to me was to simply restart the postgres with:
sudo service postgresql restart
Which is not mentioned here.
psql: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
I searching the solution for a while. So, this one fixed the issue for me as well (reinit db):
rm -r /usr/local/var/postgres
initdb /usr/local/var/postgres -E utf8
pg_ctl -D /usr/local/var/postgres -l logfile start
I use OS X 10.11.3 with brew.
In my case none of previous solutions was good. Instead of using socket, you can use TCP host + port number in Rails config file. So in database.yml file just add two lines like here:
...
adapter: postgresql
encoding: unicode
pool: 5
host: localhost
port: 5432
This solved my problem :)
Before I used this fix:
sudo mkdir /var/run/postgresql
sudo ln -s /tmp/.s.PGSQL.5432 /var/run/postgresql/.s.PGSQL.5432
But after each reboot /tmp/.s.PGSQL.5432 was deleted and I had to repeat these commands. Solution works, but it is horrible, so better just modify Rails database config file :)
Got this error when I was setting up Posgtres with Django, I'm using Back Track and it comes with Postgres installed. I assume the settings are the issue. I fixed it by removing it completely then reinstalling like so.
sudo apt-get remove postgresql
sudo apt-get purge postgresql
Now run:
apt-get --purge remove postgresql\*
to remove everything PostgreSQL from your system. Just purging the postgres package isn't enough since it's just an empty meta-package.
Once all PostgreSQL packages have been removed, run:
rm -r /etc/postgresql/
rm -r /etc/postgresql-common/
rm -r /var/lib/postgresql/
userdel -r postgres
groupdel postgres
You should now be able to:
apt-get install postgresql
MacOSX here. I had the same problem after upgrading my postresql install from a pre-9.1 to 9.1.2 using homebrew. (By the way, remember to dump databases before your upgrade with pg_dump, pre-9.1 databases are incompatible.) Same problem, same error messages.
Uninstalling the pg gem did the trick for me. I actually had to do quite a bit of dancing to discover the issue. First I did a global gem uninstall, clearing the deck of all the old gems (there were a few). Then I removed pg from my Gemfile, rebundled, restored the pg reference, and rebounded once more.
After that, it worked like a charm.
Hello world :)The best but strange way for me was to do next things.
1) Download postgres93.app or other version. Add this app into /Applications/ folder.
2) Add a row (command) into the file .bash_profile (which is in my home directory):
export PATH=/Applications/Postgres93.app/Contents/MacOS/bin/:$PATH
It's a PATH to psql from Postgres93.app. The row (command) runs every time console is started.
3) Launch Postgres93.app from /Applications/ folder. It starts a local server (port is "5432" and host is "localhost").
4) After all of this manipulations I was glad to run $ createuser -SRDP user_name and other commands and to see that it worked! Postgres93.app can be made to run every time your system starts.
5) Also if you wanna see your databases graphically you should install PG Commander.app. It's good way to see your postgres DB as pretty data-tables
Of, course, it's helpful only for local server. I will be glad if this instructions help others who has faced with this problem.
I had this problem plaguing me, and upon further investigation (running rake db:setup), I saw that rails was trying to connect to a previously used postgres instance - one which was stored in env variables as DATABASE_URL.
The fix: unset DATABASE_URL
source: https://stackoverflow.com/a/17420624/2577622
I tried most of the solutions to this problem but couldn't get any to work.
I ran lsof -P | grep ':5432' | awk '{print $2}' which showed the PID of the process running. However I couldn't kill it with kill -9 <pid>.
When I ran pkill postgresql the process finally stopped. Hope this helps.
gem uninstall pg
On OS X with Homebrew:
gem install pg -- --with-pg-config=/usr/local/bin/pg_config

Resources