newly installed postgres startup error - postgresql

I have installed postgres & also started the server. But, when I tried to start console using psql, I'm getting error like database "****"(any database) does not exists. How to resolve this error?? I don't have acces to psql shell. And is there other way to create or change startup database without accessing psql.

Related

How to start postgres service as a different user(myown) instead postgres user

I have installed postgres 9.5 in my linux(16.04) machine.I have started service using below command.
sudo service postgresql start
This will start postgres service as a postgres user.
But I want to run postgres a different user(myown user).
How can I do .Please help !!.
You have to recursively change the ownership of the database directory to the new user.
If the WAL directory or tablespaces are outside the data directory, you have to change their ownership too.
Then you will have to configure the startup script so that it starts PostgreSQL as the new user. Watch out: if you installed the startup script with an installation package, any changes to it will probably be lost after an update.
I recommend that you don't do all that and continue running PostgreSQL as postgres.

Why is pg_restore returning successfully but not actually restoring my database? PostgreSQL 9.5

I'm trying to use PostgreSQL 9.5 with pgAdmin 4 (I would prefer to use pgAdmin 3 but I get the following message when trying to connect to my database:
"Warning:
The server you are connecting to is not a version that is supported by this release of pgAdmin III.
pgAdmin III may not function as expected.
Supported server versions are 8.4 to 9.3")
So I'm forced to use pgAdmin 4. However, when I restore (like I usually do on pgAdmin III) I get a 'successful' restore but no data is actually restored into the tables.
If I click on the details of the 'successful' restore I am presented with this:
"1. pg_restore: connecting to database for restore"
How do I fix this issue?
Would you provide pgAdmin4 logs after running restore?
pgAdmin4 Log location:
Linux:
~/.pgadmin/pgAdmin4.log
~/.pgadmin/job_logs/
Windows:
%appdata%\pgAdmin\pgAdmin4.log
%appdata%\pgAdmin\job_logs\
Note: Do not close Success dialog in pgAdmin4 after restore otherwise once you acknowledge the success dialog, pgAdmin4 will delete respective job log files from "job_logs" directory & also delete "pgAdmin4.log" before running restore to trim unwanted logs.

Codeigniter connection to remote PostgreSql database

I hope someone can help. I am running codeigniter 3.05 and trying to connect to a remote PostgreSql database. If I set session to database, I get include(.../views/errors/html/error_php.php) failed to open stream error message.
No other session configuration setting generates the error. If I run a method on a model, I get the same error along with: Fatal error: Call to a member function from() on null in /opt/share/php/ci/application/libraries/ActiveRecord.php on line 295.
I run the PostgreSql client from command line and I can connect to the database ok. I am running Ubuntu 15.04 and I have checked permissions and ownership settings for Codeigniter. I had a similar problem loading the model, but, when I changed the first letter of the name of the file to uppercase, the message disappeared.
Is there a database driver that I need to change the first letter so Ubuntu can find it? Or, what else could it be?

Heroku pg:pull is giving sh: createdb: command not found

When I try to do heroku pg:pull DATABASE_URL myappspassword, I get this error:
my-computer:a-folder (master*) · heroku pg:pull DATABASE_URL myappspassword
! sh: createdb: command not found
!
! Unable to create new local database. Ensure your local Postgres is working and try again.
For once Googling doesn't return a result. I'm wondering if it's related to the fact that when I do which psql, there is no result. Maybe I need to do something special with pgAdmin to get this working (e.g. export command line tools)?
Are you on a Mac, by chance, and using Postgres App?
If so, the problem might be that createdb isn't on your path. Try adding it by inserting the following into ~/.bash_profile.
export PATH=$PATH:/Applications/Postgres.app/Contents/Versions/9.4/bin
Then run source ~/.bash_profile and try again.
There's more info on the Postgres App site: http://postgresapp.com/documentation/cli-tools.html
Your instincts are correct. You need to be able to access the Postgres from your command line. pg:pull is attempting to create a new local database and drop the relevant data from your Heroku database into it. From the docs:
This command will create a new local database named “mylocaldb” and then pull data from database at DATABASE_URL...
Basically, your local machine is trying to run createdb locally but your terminal isn't recognizing it.
I battled this damn error for a few hours. I can't say for certain if this will work for everyone but I found my issue stemmed from running the command via iTerm/ZSH instead of just normal bash. I opened up plain-old vanilla terminal, ran the command, and everything fired off like it should.

Google Cloud MySql Instance An unknown error occurred when importing

I created a mysql instance and everything is running on it. I used the process outlined in the cloud sql import to create a mysqldump file from my local production mysql instance running on windows.
mysqldump --databases xxxxx -uroot -p --hex-blob --default-character-set=utf8 > d:\database_file_feb2_2014.sql
Uploaded the file to the cloud storage and every time I try to import I get a Unknown error.
Things I have checked.
1) Made sure the USE database; command was in the file after the
CREATE DATABASE IF NOT EXISTS databasename;
command.
2) Made sure i was using the --hex-blob command.
created a export of smaller test db which was only 4.5MB instead of the 6GB file i was trying to import. Ran the first few lines from the sql prompt which ran fine.
Still unable to isolate at which line the import is breaking or Why
When I try to view the log from the old console, I get "An error has occurred. Please retry later."
I have dumped the whole instance and recreated the instance and still get the same error.
Origin OS: Windows Server 2003 R2
Running Mysql 5.1
Any advise on how I can troubleshoot this and move forward.
Thank you