Setup Rails 3.1 and Postgresql on Snow Leopard - ruby-on-rails

I have spent countless number of hours trying to setup PostgreSql on my Intel Mac.
I am able to install Rails and all but PostgreSql would not get installed on my Mac.
Anybody has any solution or any tutorial which I can follow to install it ??
P.S. I just started using Mac as my development machine. I have been using Windows before that !

Ok I had to do a little more research with a fresh mind and I am now able to solve the problem myself. Here is the solution :
Install Homebrew using this command :
ruby -e "$(curl -fsSLk https://gist.github.com/raw/323731/install_homebrew.rb)"
Once installed write this in your terminal :
brew install postgres
If this is your first install ( which was the case with me ) than type this in terminal after the above step:
$ initdb /usr/local/var/postgres
To start the postgresql type this in terminal:
pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start
After the above step type this :
ps auxwww | grep postgres
If the result of the above command in terminal looks like this than that means the postgresql is installed correctly :
26000 0.0 0.1 2445860 1556 ?? Ss 1:59AM 0:00.05 postgres: autovacuum launcher process
25999 0.0 0.0 2445728 512 ?? Ss 1:59AM 0:00.15 postgres: wal writer process
25998 0.0 0.0 2445728 912 ?? Ss 1:59AM 0:00.21 postgres: writer process
25996 0.0 0.1 2445728 2508 ?? S 1:59AM 0:00.15 /usr/local/Cellar/postgresql/9.0.4/bin/postgres -D /usr/local/var/postgres
26257 0.0 0.0 2435548 0 s000 R+ 2:19AM 0:00.00 grep postgres
Create a user and database:
createuser username
createdb -Ousername -Eutf8 databasename
To login to postgresql use this command:
psql -U username databasename
If you are using it with rails you can install the gem like this :
sudo env ARCHFLAGS="-arch x86_64" gem install --no-ri --no-rdoc pg
If you would like to stop the PostgreSQL service use this command :
pg_ctl -D /usr/local/var/postgres stop -s -m fast
Hope this will help others in saving the time of going through different resources to come with the solution like I did :)

Try using Cinderella. That will give you the whole stack (including MongoDB, Redis, and a whole bunch of other stuff) in one nice neat bundle in ~/Developer. You're better off using custom builds of all your development tools so that you don't have to worry about what version of anything comes with the system and what an upgrade might to do your OS.
References:
Cinderella on Github
Cinderella Homepage

A few other notes to add to your instructions:
There is a good post at Russ Brooks Blog on installation which validates much of what you have above.
There are a set of admin tools available at pgadmin.org which will allow you to browse your database through a simple GUI on the Mac
If you use the admin tools you should install the instrumentation pack with the following:
psql -d postgres < /usr/local/Cellar/postgresql/9.0.4/share/postgresql/contrib/adminpack.sql
where the exact command obviously depends on the version of postgresql you are using.
If you are using postgres with rails and bundler then make sure the "pg" gem is in your gem file and run bundler with the following command immediately after you add it:
env ARCHFLAGS="-arch x86_64" bundle install
This will do the same as your 'gem install' command above. After you run it for the first time you no longer need to use the 'env ARCHFLAGS="-arch x86_64"' when you run bundler.

I had luck downloading and installing it straight from the site:
http://www.postgresql.org/download/macosx

I have used MacPorts for most of my server/low level program installations (PostgreSQL, MySQL, etc.). If you choose to go that route, you can then follow this blog post/tutorial on installing PostgreSQL via MacPorts onto your Mac. One thing to note on the PostgreSQL link: when following along, change the instances of 83 to 90. For example, you will see this in his steps:
sudo port install postgresql83 postgresql83-server
You can instead, type this to get the newest version of PostgreSQL
sudo port install postgresql90 postgresql90-server
I would also recommend grabbing a program such as Navicat for PostgreSQL Lite. It's free and nice to have to manage your local PostgreSQL DBs.
If you don't want to go with MacPorts, there's a similar alternative called HomeBrew that's quite popular ... I'm just too lazy to switch from MacPorts :).

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.

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.

Install sqlite3 on mac osx?

I just bought a new MBP
I've read online Sqlite3 already exists on OSX.
I've downloaded mac ports (and installed it) as well as the bin file for sqlite3 from the official web site.
In a guide I'm reading about rails, which tells me to update sqlite3, I run the following in terminal: sudo port upgrade sqlite3
I receive the following error: Error: sqlite3 is not installed
I am so lost! Please help
I don't remember the default configuration, but like you i installed sqlite myself. You can check your sqlite installation is complete by typing using the which command in the OS X terminal:
$ which sqlite3
/opt/local/bin/sqlite3
If which doesn't reveal anything, then sqlite3 isn't in your system's PATH. Use the cat command to see how that's set up (in your /etc/profile file;)
$ cat /etc/profile
# System-wide .profile for sh(1)
if [ -x /usr/libexec/path_helper ]; then
eval `/usr/libexec/path_helper -s`
fi
if [ "${BASH-no}" != "no" ]; then
[ -r /etc/bashrc ] && . /etc/bashrc
fi
export PATH="/usr/local/bin:/usr/local/sbin:$PATH"
export PATH="/usr/local/mysql/bin:$PATH"
export PATH="/opt/svn/subversion-1.4.3/bin:$PATH"
export PATH="/opt/ruby/bin:$PATH"
export PATH="/opt/sqlite/bin:$PATH"
You can open that file in a text editor and add the path to the lines at the bottom. You can see I've installed sqlite to /opt/sqlite, not /usr/local, so i've had to add that to my path. This tells the system to check there for executable files when a command is given.
Once that's done you need to ensure that Ruby has the functionality it needs to interact with sqlite. We do that by installing the sqlite3 gem. Maybe you don't need to:
$ sudo gem list
Password:
*** LOCAL GEMS ***
# ...loads of gems listed ...
sqlite3-ruby (1.2.4)
# ... loads of gems listed ...
If it's not there, `sudo gem install sqlite3-ruby' will sort you out in no time. Rails should work with sqlite out of the box if you take those two steps.
To install the sqlite gem the binary won't be enough afaik. You'll need the amalgamation tarball from the sqlite website or install it via ports:
sudo port install sqlite3
I've seen many posts that recommend you install XCode Tools. I already had XCode 3.2 Installed. Installing XCode from the CD didn't help.
What did help is the following:
sudo env ARCHFLAGS="-arch x86_64" gem install sqlite3-ruby
I believe the "env ..." statement will also help if you're trying to install mysql on Snow Leopard.
It's not installed via mac ports, so port doesn't know about it. You could either do an install via port or get rails to use the one that's installed on the Mac already.

Resources