I'm trying to install postgres 9.2 on a mac 10.6 using using KyngChaos (because ultimately I'd like to enable PostGIS, and this seems to be the best package to that with).
I get exactly the problem spelled out at the bottom of the page: http://www.kyngchaos.com/software/postgres
--
NOTE: I've had reports of the installer not initializing the data cluster, which results in Postgres not starting. It seems to be random, and I haven't figured out the cause yet. If Postgres won't start (you get an error "could not connect to server: No such file or directory" when trying to connect with psql), try manually initializing the cluster with:
/usr/local/pgsql-9.1/bin/initdb -U postgres \
-D /usr/local/pgsql-9.1/data --encoding=UTF8 --locale=en_US"
Or see the Locales and Encodings readme if you need a different locale or encoding.
Then stop and start Postgres as specified in the readme.
--
I run
/usr/local/pgsql-9.1/bin/initdb -U postgres -D /usr/local/pgsql-9.1/data --encoding=UTF8 --locale=en_US"
which opens up a new line to enter additional commands with
>
but i'm lost there, even after combing the readme.
Related
I have a postgreSQL 9.6 installation on Ubuntu 16.04, provided by the EnterpriseDB. I've been connecting to the local server and using it for a number of months. I figured I should backup the server at this point, so I tried using the pg_dump command as follows:
cd to postgres bin at /opt/PostgreSQL/9.6/bin
Run pg_dump via sudo pg_dumpall > /sata_ssd2/pgdump/0419.bkp
This gives an error: Error: You must install at least one postgresql-client-<version> package. I tried installing via: sudo apt-get install postgresql-client-9.6 but that package does not seem to exist.
I also tried to run pg_dump and pg_dumpall via pgAdmin4. It first made me fill in the binary paths for EDB Advanced Server Binary Path and PostgreSQL Binary Path; I put in opt/PostgreSQL/9.6/bin/, which is where the pg_dump executable is. When I tried to run the backups, I got the error: 'ascii' codec can't decode byte 0xe1 in position 1: ordinal not in range(128). I found an answer to this elsewhere that recommended changing from client_encoding = SQLascii to client_encoding = utf8 in postgresql.conf, but this did not help.
Does anyone have any advice on where to go from here?
In a unix/linux system the current directory . is not on the PATH and not searched for binaries.
If you want to run the command pg_basebackup in /opt/PostgreSQL/9.6/bin/, you run /opt/PostgreSQL/9.6/bin/pg_basebackup.
If you did want to run the command pg_basebackup that you knew was in the current directory you could write ./pg_basebackup instead. But just using the full path rather than cding unnecessarily is better.
I have a database running on SQL Server (13.01) on Windows. I like to deploy it to the Docker Container on Linux using SSDT.
I can perfectly connect to the server running on Docker and create/drop database manually and play with the data.
The problem is I can not publish it. I'm executing following script on Powershell
PS: SqlPackage.exe /Action:Publish /SourceFile:"d.dacpac" /TargetConnectionString:"server=containeraddress;database=thedatabase;user id=sa;password=thepassword;
and getting the following error.
Unable to connect to master or target server 'the database'. You must have a user with the same password in master or target server 'the database'. (Microsoft.Data.Tools.Schema.Sql)
I have the same user and same password on target and source servers.
Is there anybody has the same problem and know how to solve it?
I'll post this here as most of the answers refer to having an existing compiled dacpac file, which may not always be possible. I haven't seen similar ideas posted elsewhere to the solution I'm suggesting here.
Given your usage of docker and if you wish to compile your visual studio project inside the container, given certain combinations of the container base OS and image may not be possible to create a dacpac file with msbuild.
You can work around restoring the database using a series of unix based commands, taking note that the visual studio database project is usually just a series of SQL files, below I show an example of this, where I concat the SQL files into a single file and call sqlcmd to run the script;
FROM mcr.microsoft.com/mssql/server
WORKDIR /init
ENV ACCEPT_EULA=Y
ENV MSSQL_SA_PASSWORD=MyPassword
EXPOSE 1433:1433
RUN apt-get update && apt-get install dos2unix
COPY /solution_folder/database/Tables/*.sql /init/
WORKDIR /database
RUN echo "CREATE DATABASE [database_name];\nGO\nUSE [database_name];\n” >> /database/create.sql
RUN for f in /init/*.sql; do dos2unix $f; cat $f >> /database/create.sql; echo "\nGO\n" >> /database/create.sql; done
RUN ( /opt/mssql/bin/sqlservr --accept-eula & ) | grep -q "Service Broker manager has started" && /opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P ‘MyPassword’ -i /database/create.sql && pkill sqlservr
The reason for "dos2unix" is that the SQL files created within visual studio have unique hidden cr/lf (and other characters) which the linux version of sqlcmd won't interpret successfully and will cause errors (which is kind of bizarre and this is exactly the kind of thing you'd want a cross platform database to be able to cope with)
Also, within the final run command you have to start-up the sql server service temporarily otherwise you'll also get errors; it's a little bit of work-around, and a bit fiddly and I'm not sure entirely that the microsoft sql server linux container is well designed enough for the simple task of restoring a database like this, the nuances are the differences between building and running a container and needing some sort of happy middle ground of both concepts for it to work.
Given here isn't a complete solution to restore, it only deals with Tables from the project file, although it should be trivial to expand to scalar functions and stored procedures.
Which version of SqlPackage.exe are you using? Only the most recent release candidate versions of SqlPackage.exe support SQL Server vNext CTP. The SqlPackage release candidate can be downloaded here: https://www.microsoft.com/en-us/download/details.aspx?id=54273
I'm trying to restore a backup in postgreSQL pgAdmin and I get the following error message:
C:\Program Files\PostgreSQL\8.2\bin\pg_restore.exe -i -h localhost -p 5432 -U postgres -d gsan_comercial -v "C:\Users\usr\Desktop\GSAN\Data Base\gsan_comercial_pmss.backup"
pg_restore: [archiver] unsupported version (1.11) in file header
Process returned exit code 1.
I can not find the reason for this.
Tks
The version you find in the dump file header is related to the version of the tools used to do the dump, i.e., pg_dump. It is possible to dump an 8.2 database using pg_dump from a later version (for example one from the 8.4 distribution) because all tools are backward compatible but in the end you'll get a file that can only be restored using the new tools.
I suppose that is what happened and you're now trying to restore an 8.2 dump done using 8.4 tools on a pgAdmin using 8.2 tools.
I want to use the pre-installed postgresql on my local machine (mac os 10.7.5), when I run which psql I find it (in /usr/bin/psql), but then running
pg_ctl -D /usr/bin/psql -l /usr/bin/psql/server.log start
results in:
-bash: pg_ctl: command not found
How can I start/use my postgresql database? do I need to install it (with say Homebrew) or can I use the pre-installed one on my mac?
I also tried using the initdb command (initdb /usr/bin/psql -E utf8) and also go tthe same message: -bash: initdb: command not found.
Also, is this psql the same as postgres? (I tried which postgres and got nothing)
Update: I'm using psql commands in the command line, but am getting there the following message (for psql -l and psql -a for instance):
psql: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/var/pgsql_socket/.s.PGSQL.5432"?
OS X ships with the command line client (for interacting with postgres databases) not the server.
You need to install the server.
Check the postgres site or grab the postgres.app
I'm trying to install PostgreSQL on Cygwin as a user following the instructions given in the cygwin package installation:
cygrunsrv -S cygserver
initdb -D /usr/share/postgresql/data
pg_ctl start -D /usr/share/postgresql/data -l /var/log/postgresql.log
createdb
psql
After I do the third step, I get the following output in the terminal,
$ postgres -D /usr/share/postgresql/data
LOG: database system was shut down at 2013-04-12 19:04:33 PDT
LOG: autovacuum launcher started
LOG: database system is ready to accept connections
After that, I'm unsure on what to do since I never see the command line again(the "$" sign). I'm a complete beginner when it comes to databases, so are there any 'for dummies' pointers for me?
Use pg_ctl -D /usr/share/postgresql/data -l /path/to/write/log/to start if you want the server to start up and background its self.
I strongly recommend reading the PostgreSQL tutorial and manual, which cover this in detail.