Problem with Mongo DB using Mongoid Gem - ruby-on-rails

I'm developing on Ubuntu, I have installed the mongoid gem, and when I run the rails server, I get this error
/home/username/.rvm/gems/ruby-1.9.2-p180/gems/mongo-1.3.1/lib/mongo/connection.rb:518:in `connect': Failed to connect to a master node at localhost:27017 (Mongo::ConnectionFailure)
I remembered using a command like brew install but I am pretty clueless. Am I missing something? Thanks in advance!

You need to have MongoDB installed, too. Since you're on Ubuntu, try this:
sudo apt-get install mongodb
If you saw any brew commands in any instructions you were reading, those were likely for Homebrew on Mac OS X, not for Ubuntu.

other possibility
you didnt start the server(which should auto-start usually)
mongod also has this weirdness
try to run sudo mongod in a foreground process
and the messages should tell you how to recover

Related

How do I get 'psql' (from pgadmin4) installed on Fedora 34?

I am attempting to install 'pgadmin4' on a Fedora 34 VM (AWS AMI EC2), but it is not installing 'psql'
I ran these commands:
sudo rpm -i https://ftp.postgresql.org/pub/pgadmin/pgadmin4/yum/pgadmin4-fedora-repo-2-1.noarch.rpm
sudo yum install pgadmin4-desktop
and psql is no where to be found
I ran: sudo find / -type f -name psql, and nothing was found.
How do I get psql installed on Fedora 34?
I do not want to install the server / database. I just need 'psql' on the system. I do not need or want the web components.
I have lost about three hours with this, extremely frustrated.
I have searched and searched, tried a number of things.
It will be a miracle if I can get this working, if anyone has any ideas or has actually installed pgadmin4-desktop successfully or found a way to get psql onto a system (without installing the database software).
I just need the psql client.
Thank You,
Try
sudo yum install postgresql
pgadmin4-desktop sounds like GUI to me. If you need server it's in postgresql-server

Install Mysql 5.7 on High Sierra

I want to install mysql 5.7 on my Mac OS 10.13.5. However, brew install mysql installs version 8.0 which is not suited for my project. Forgive me if this question was asked before but I could not find a solution.
Now it's bit differently
brew install mysql#5.7
$ brew install mysql55
This installs a specific version 5.5 which exists along with 8.0
Also mysql entry should be added to .bash_profile to make sure it load and then server start should be done.
$ brew services start mysql#5.5
Below command gives the sequence of how the files are loaded in sequence.
$ mysql --verbose --help | grep my.cnf
order of preference, my.cnf, $MYSQL_TCP_PORT,
/etc/my.cnf /etc/mysql/my.cnf /usr/local/etc/my.cnf ~/.my.cnf
While installing first mysql server instance works perfectly, installing a different version of mysql instance should be configured properly and the paths of installation, log files and other components have different path.
Installation paths be found here, for eg.
mysql -> ../Cellar/mysql/8.0.11/bin/mysql

Rails 4 + PostgreSQL 9.6 hstore, can't execute “CREATE EXTENSION hstore”

I need to get Hstore to work for Rails application that I'm working on. I'm running Linux Mint 18 and psql (9.6.1, server 9.5.5) and postgresql-contrib 9.6. As far as I'm aware, hstore should be installed and enabled by installing the postgresql-contrib. However when I load the psql console and do \dx I don't see the Htop showing in the "installed extensions". When I run
CREATE EXTENSION hstore;
I get the error
ERROR: could not open extension control file "/usr/share/postgresql/9.5/extension/hstore.control": No such file or directory
Any help would be very appreciated. Thanks.
There are two possible solutions:
sudo apt-get install postgresql-contrib-9.*
where 9.* is your postgres version,
or simply reinstall pg gem.

So I installed postgresql and localhost port conflicting with ruby app?

I installed postgresql. I put the localhost port to 3000 on pgadmin. Then it started to throw this error since the localhost port for my ruby app is also at port 3000.
Address already in use - bind(2) for "localhost" port 3000 (Errno::EADDRINUSE
I tried to uninstall it and the error still comes up. I tried to delete pgadmin. I tried to set an environment variable export PGPORT=5432. After all this the error still comes up. I just want to get rid of postgres and re-install everything to see what went wrong. I am completely confused. I am faily new with ruby and postgres. I usually use node mongodb etc.
Questions:
What is the best way to get rid of postgresql and reinstall it?
Any other ideas on how to edit the port?
How to delete db on postgresql?
I know it sounds like I am all over the place because I am right now. I just want to start fresh. So please any help.
Best way to install and use PG/Mongo/MySql on Mac OSX is Brew.
If brew not installed, install it by copy/pasting into Terminal.
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
To install Postgresql
brew install postgresql
To use DB (run/restart/stop)
brew services list
brew services start postgres
brew services stop postgres
you may also use different port.
rails s -p 81
if you want to always start with different port..create Rakefile and add a task..
task :server81 do
`bundle exec rails s -p 8081`
end
you can use it directly by rake server81

What is the easiest way to get Postgresql set up on OSX?

Wondering if anyone could help me? I've recently switched over to Mac and trying to set up my Rails environment. I want to set up Postgresql as my database since I used it with my Windows development. The trouble is, there are a number of different ways to set it up and I just wanted to know which would be the best and error free.
I have homebrew installed too, I see it is available to download through there but has anyone had any experience through this route?
Cheers
Postgres.app is the easiest way to run PostgreSQL on the Mac
Almost same answer but using homebrew:
brew install postgresql
Get mac ports from http://www.macports.org/
sudo port install postgresql84; sudo port install postgresql84-server
You may need to tweak pg_hba.conf to allow connections from ::1 (IPv6 localhost).
Alternately, from source:
ARCH=x86_64 CFLAGS="-arch x86_64" LDFLAGS="-arch x86_64"
./configure --prefix=/usr/local/pgsql --with-libxml --with-libxslt --with-openssl
make
sudo make install
sudo su postgres -c '/usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data/'
sudo su postgres -c '/usr/local/pgsql/bin/pg_ctl -D /usr/local/pgsql/data/ -l /var/log/pgsql/postgresql.log start'
sudo chown -R postgres /usr/local/pgsql/
You could use cinderella to get the whole PostgreSQL, MongoDB, Ruby, ... stack in one go. The initial install takes awhile but it puts everything in ~/Developer so it is easy to keep track of and easy to clean up.
Just get the PostgreSQL OSX installer, provided by EnterpriseDB.
You might consider http://postgresapp.com/.
It claims to be "the easiest way to run PostgreSQL on the Mac" and so far it has been true for me.

Resources