Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
SET UP:
I have OS X Lion 10.7.2 installed (not upgraded)
I bought the laptop (no software upgrade)
I have Version 4.2 (4D199) installed
My .bash_profile says the following:
export PATH="/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:$PATH"
export PATH="$HOME/.rbenv/bin:$PATH"
When I type 'which psql' I get:
/usr/bin/psql
I have read this post on fixing the postresql Repairing Postgresql after upgrading to OSX 10.7 Lion and in this article it says that the when you type which psql you should be getting:
usr/local/bin/psql
I'm not getting it. What am I doing wrong?
UPDATE - FOR ANYONE
If anyone has the same set up as me do the following: Read this link https://plus.google.com/114301087219148980063/posts/VHmzi63jCJK I have copied and pasted what this person has wrote:
If you've installed or upgraded to Lion, you probably noticed that it now comes with a partial PostgreSQL 9.0.4 installation. Replacing shoddy MySQL with proper beardy Unix database software is no doubt a good thing, but you will quickly notice that the actual PostgreSQL server is missing, as it's part of the "server" version of Lion and not included in the regular flavor. So how do you get your PostgreSQL development server back?
Do not buy Lion Server http://itunes.apple.com/gb/app/os-x-lion-server/id444376097?mt=12. For £35 this should get you the official build of the server part of PostgreSQL, along with a lot of other stuff you most likely don't need. Save the cash and the diskspace.
Do not install the official PostgreSQL Mac package from EnterpriseDB http://www.enterprisedb.com/products-services-training/pgdownload. It's nice of them to provide one, but it's currently not working with Lion (minor user creation issues - although there is a workaround).
Do not Build from source http://cambhlumbulunk.blogspot.com/2011/07/os-x-lion-2-postgresql-as-default.html. This will work, but leave you with a clutter of files in /usr/local that conflict with system files unless you're taking special care.
Do brew install postgresql. Yes, this is almost the same as 3., but the result can be easily removed or updated later. Plus you get nice setup instructions at the end about how to create a database and launch postgres at login. Homebrew Link will also help you set up your environment so that things that require PostgreSQL headers and includes to build (like psycopg2) can find them without any messing around.
FINAL NOTE:
You must have brew installed first.
After you have installed brew then you can install postgresql brew install postgresql
The installation provides EXCELLENT notes for creating your initial DB and starting/stop PostgresSQL for OS X Lion. Save the notes and do the initial create DB
Once you have at this point you can create a db. i.e. psql -d stuff
For the longest time I kept wondering why the initial OS X Lion PostgreSQL was not working and it comes down to it's missing the server version. Anyone else banging their heads on this I hope this reference material helps.
*.bash_profile* is read on login (if you're using bash as your login shell or if you force its execution with the --login option).
Did you try to log off and on after you've modified the initialization file (*.bash_profile* will not be read if you just open a new terminal window)?
You may add the path settings to your .bashrc file too (it's read whenever an interactive shell is spawned).
Did you check if psql is actually available in /usr/local/bin ?
Related
I have a data ware house running on PostgreSQL and I would like to check what all are the missing indices are in my database.
I tried to install the extension pg_qualstats but it is giving the below error.
root#Ubuntu-1604-xenial-64-minimal ~ # sudo pip install pg_qualstats
Collecting pg_qualstats
Could not find a version that satisfies the requirement pg_qualstats (from versions: )
No matching distribution found for pg_qualstats
You are using pip version 18.1, however version 19.2.3 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
root#Ubuntu-1604-xenial-64-minimal ~ #
So how can i install this extension? I tried the CREATE EXTENSION pg_qualstats but it was giving error.
Also is there any other database maintenance need to be done for the database regularly?
What all parameter I have to check?
Can we automate the maintenance activity?
I was a SQL server DB admin and it was much easier to find out the missing index, understand the execution plan, DB maintenance but I find it hard, when it comes to PostgreSQL.
So any guidance will be of great help.
I am only answering the immediate question regarding the installation of pg_qualstats - the rest of the questions are way too broad for a platform like stackoverflow (or dba.stackexchange).
Many interesting extensions are provided as source code in Postgres (that's one of the reasons why it's highly recommended to run Postgres on Linux, because compiling the extensions is way easier in Linux than it is on Windows, and may extensions are only developed for Linux).
pg_qualstats is no different.
It is provided together with PoWA and the installation of the extension is documented as part of their installation guide
In a nutshell:
Download the source:
wget https://github.com/powa-team/pg_qualstats/archive/1.0.7.tar.gz -O pg_qualstats-1.0.7.tar.gz
tar zxvf pg_qualstats-1.0.7.tar.gz
cd pg_qualstats-1.0.7
the compile it:
make
make install
Register the shared libraries by editing postgresql.conf and after restarting Postgres the extension can be created using CREATE EXTENSION pg_qualstats;
I've had as few issues trying to upgrade postgresql-server. I've reverted back to the older version now (9.0.3) and the service is running and accessible via pgadmin/other gui tools.
However, I can't access it via the psql command (as user postgres). This may be possibly because the psql binary seems to be missing. I feel this may have happened when I uninstalled a version of postgres that I had intended to revert to.
I can't reinstall version 9.0.3 because the repo is no longer valid.
Is there any way I can install only the psql binary file and nothing else. I was considering copying the psql binary file from another server, although because the other servers have different versions of postgresql, I'm not sure if this is a good idea (?)
I think psql binaries didn't disapear from your system.
It's just that you had symbolic links from /usr/bin to your 9.0.3 binaries.
When you installed a newer version, this links where replaced to point to the new version and when you uninstalled it, they were dropped.
Try locate to find your binaries. Then you would be able to recreate your symbolic links in /usr/bin.
If you want to try 9.0.3 - you can always build it from source:
https://www.postgresql.org/ftp/source/v9.0.3/
But many distros package pqsl-client seperate from the server and you can use a newer version of psql instead (or at least try).
There are also archives of almost any distro out there and you could fetch that single rpm/deb packge from there.
I uninstalled my PostgreSQL because I'm trying to use version 9.1.9. I tried reinstalling it. It successfully installed from what I can see.
However, when typing in psql --version on the command line, I get that it is still using version 9.0.10
How can I make it use the new version?
psql is the command line interface and its version can be independent of the Postgres server.
To get the version of the server software run SELECT version() against the database you are connected to (from within psql). Though it is possible to interact with different versions, some obvious limitations apply. I suggest you uninstall the outdated psql as well and use the version matching the server.
If you're running this on a UNIX/Linux system the problem is likely to do with where psql is being called from. It doesn't sound like the old version got removed and you're still calling it when you run psql. Try running this:
which psql
That will tell you the full path of what gets invoked when you run just psql. To see if there are other instances of psql installed on your system try running:
sudo updatedb
(you'll need to put in your password here). And then:
locate psql
Your system likely uses some kind of package manager, which controls which packages are installed. For example, Ubuntu/Debian use dpkg, Redhat uses yum, you may be using something like fink or macports if you are using OSX.
I will keep it short for the people who don't want to read too much. Currently, I am trying to run PostgreSQL.app 9.3.0. (Homebrew didn't work and complained that there might be conflicting versions).
It seems to run pretty well, however my psql's version is 9.1.0 and it causes some problems. Psql is probably a left over from another installation/uninstallation maybe a year ago.
Is there a way to update psql or locate it so that I can re-install it. Maybe these two screenshots maybe will give you an idea.
Thank you!
http://i.imgur.com/u3H4hxJ.png
http://i.imgur.com/DaBnzTi.png
Use the 'which' command in the terminal to determine the path/location of the command in question. For example:
$ which psql
/Library/PostgreSQL/9.3/bin/psql
The first image you posted is likely a result of running the psql that comes with default OS X installs. That version is located at:
/usr/bin/psql
I wouldn't recommend removing it however. Instead, once you've installed a version of psql that matches your server (or perhaps it's already there but is just behind the other version in your path), update your path so that the proper psql command comes before the default OS X one and any others. If you are using bash as your preferred shell, for example, then put this in your ~/.bash_profile file:
# add PostgreSQL binaries to the path
export PATH=/Library/PostgreSQL/9.3/bin:$PATH
How can I get PDO to work on my mac (os x 10.5)? I'm using the built in php and php in Zend/Eclipse. Can't seem to find useful drivers for it at all.
I had to install the PDO_PGSQL driver recently on Leopard, and I ran across a multitude of problems. In my search for answers, I stumbled across this question. Now I have it successfully installed, and so, even though this question is quite old, I hope that what I've found can help others (like myself) who will undoubtedly run into similar problems.
The first thing you'll need to do is install PEAR, if you haven't done so already, since it doesn't come installed on Leopard by default.
Once you do that, use the PECL installer to download the PDO_PGSQL package:
$ pecl download pdo_pgsql
$ tar xzf PDO_PGSQL-1.0.2.tgz
(Note: you may have to run pecl as the superuser, i.e. sudo pecl.)
After that, since the PECL installer can't install the extension directly, you'll need to build and install it yourself:
$ cd PDO_PGSQL-1.0.2
$ phpize
$ ./configure --with-pdo-pgsql=/path/to/your/PostgreSQL/installation
$ make && sudo make install
If all goes well, you should have a file called "pdo_pgsql.so" sitting in a directory that should look something like "/usr/lib/php/extensions/no-debug-non-zts-20060613/" (the PECL installation should have outputted the directory it installed the extension to).
To finalize the installation, you'll need to edit your php.ini file. Find the section labeled "Dynamic Extensions", and underneath the list of (probably commented out) extensions, add this line:
extension=pdo_pgsql.so
Now, assuming this is the first time you've installed PHP extensions, there are two additional steps you need to take in order to get this working. First, in php.ini, find the extension_dir directive (under "Paths and Directories"), and change it to the directory that the pdo_pgsql.so file was installed in. For example, my extension_dir directive looks like:
extension_dir = "/usr/lib/php/extensions/no-debug-non-zts-20060613"
The second step, if you're on a 64-bit Intel Mac, involves making Apache run in 32-bit mode. (If there's a better strategy, I'd like to know, but for now, this is the best I could find.) In order to do this, edit the property list file located at /System/Library/LaunchDaemons/org.apache.httpd.plist. Find these two lines:
<key>ProgramArguments</key>
<array>
Under them, add these three lines:
<string>arch</string>
<string>-arch</string>
<string>i386</string>
Now, just restart Apache, and PDO_PGSQL will be up and running.
Take a look at this PECL package: PDO_PGSQL
I haven't tried it myself, but I've been interested in playing with Postgres as an alternative to MySQL. If I have a chance to try it soon, I'll throw my results up here in case it helps.
I'm not sure this will help with the PDO drivers specifically, but you might look into BitNami's MAPPStack.
I had a ton of trouble with Postgres, PHP, and Apache on my Mac, some of it having to do with 64- vs 32-bit versions of some or all of them. So far, the BitNami MAPPStack install is working nicely in general. Maybe it will help with your PDO issues as well.
Install new php version via brew and restart server, and php -v, all issues are removed.
This is what worked for me
brew install php55-pdo-pgsql
This installs PHP 5.5.32 and PostgreSQL 9.5. I already had PostgreSQL 9.4 installed so I uninstalled the homebrew version with:
brew uninstall postgres
You then have to update /etc/apache2/httpd.conf to point to the correct PHP version and restart Apache:
LoadModule php5_module /usr/local/Cellar/php55/5.5.32/libexec/apache2/libphp5.so
My OSX version is Yosemite.