I have a scenario where I need to copy production database to my dev database on daily basis. Both are different servers. What I have thought of writing a cronjob that will do the stuff. I have written a php script. I am connecting to remote production server via sshpass, taking its dump and then populating that dump.
exec("sshpass -p 'mypassword' ssh root#IP_ADDRESS:PORT");
exec("mysqldump -u root -p DB > production_dump.sql");
exec("mysql -u root -p test < production_dump.sql");
But at first line it throws error of stating
ssh: Could not resolve hostname IP_ADDRESS:PORT: Name or service not known
I have tried given solution on internet but non of them worked. Can any on please explain what I am doing wrong?
Your command is failing because it's not formatted right. You need to use one of the following formats:
sshpass -p 'mypassword' ssh root#IP_ADDRESS PORT
sshpass -p 'mypassword' ssh root#IP_ADDRESS -p PORT
sshpass -p 'mypassword' ssh ssh://root#IP_ADDRESS:PORT
However, I'm not sure if the rest of the script will work, especially if it starts asking for a password. A bash script would be the way to go.
AgensGraph can not startup.
When AgensGraph installed multiple instance on same server, Some AgensGraph can't startup.
$ ag_ctl start
ag_ctl: another server might be running; trying to start server anyway
server starting
Is there config parameter about it?
There is configuration parameter of port number on "postgresql.conf" file.
See the directory "$AGDATA", you can found "postgresql.conf" file.
$ grep ^#port $AGDATA/postgresql.conf
#port = 5432 # (change requires restart)
$ vi $AGDATA/postgresql.conf
<<< FIX Port Number >>>
$ grep ^port $AGDATA/postgresql.conf
port = 9999 # (change requires restart)
After fix port number, Restart your AgensGraph.
$ ag_ctl restart
waiting for server to shut down..... done
server stopped
waiting for server to start.... done
server started
After restart, you can access to AgensGraph on new port number.
$ agens -p 9999
agens (AgensGraph 2.1.0, based on PostgreSQL 10.4)
Type "help" for help.
agens=#
I try to set up a PostgreSQL-server (to learn Spring).
As I am new to PostgreSQL, I have difficulties to frame my problem.
Problem description:
I started postgresql:
● postgresql.service - PostgreSQL RDBMS
Loaded: loaded (/lib/systemd/system/postgresql.service; enabled; vendor preset: enabled)
Active: active (exited) since Mo 2017-08-21 19:10:46 CEST; 20min ago
Process: 28211 ExecStart=/bin/true (code=exited, status=0/SUCCESS)
Main PID: 28211 (code=exited, status=0/SUCCESS)
PostgreSQL is running on my local machine (Ubuntu 16.04). So no remote server ect.
Trying to populate Postgres with data:
sudo psql -h 127.0.0.1 -U postgres -f create_soba_psql.sql
Password for user postgres:
psql: FATAL: password authentication failed for user "postgres"
FATAL: password authentication failed for user "postgres"
Tried pw: postgre, postgres, with pw from current user of OS
BUT
sudo -u postgres psql
creates a connection
(with pw from current user of OS).
So something new to me to be learned...
What I already tried:
Resetting pw for postgres with: $ sudo passwd postgres
Looking into the PostgreSQL Client Authentication Configuration File
screenshot configuration
I think "peer" should be ok, as I do not connect to a remote server, isn't it?
Reinstalling PostgreSQL and trying everything again. At least the error did not change...
Do you, dear reader, have a hint what I can try or even have a solution/ explanation what I am doing wrong?
Kind regards,
Niklas
do:
sudo -u postgres psql
in psql session, run:
alter user postgres password 'some_pw';
quit the session and try:
sudo psql -h 127.0.0.1 -U postgres -f create_soba_psql.sql
when asked use password some_pw
while trying to log in using this .. mssql -u sa -p mypassword .i get this error, Error: Failed to connect to localhost:1433 - connect ECONNREFUSED 127.0.0.1:1433
I have installed sql server on docker using this https://www.microsoft.com/en-us/sql-server/developer-get-started/java-mac tutorial and started it.
I am using mac os sierra. I have searched all over internet including stackoverflow for this but gotten no answer. The only answer i get is to enable tcp/ip using sql configuration manager, but mac os doesn't have a configuration manager so I can enable the tcp/ip. Kindly assist.
I finally found the solution .. the docker set the memory as 2GB while the MS SQL server requires 3.25GB... All i had to do was go to the Docker preferences and changed the memory to 4GB and it works :). I was using sql server on docker on Mac.
I'm using docker to set up containers and then sql-cli to access SQL server. This is how I resolved that error which I got after providing mssql -u sa -p mypassword.
What I didn't realize at the beginning was a too simple password provided before with setting up a docker container:
docker run -d --name Homer -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=myPassw0rd' -p 1433:1433 microsoft/mssql-server-linux
The Terminal doesn't say this and only after going to docker > Kitematic and checking the logs of the just created container I saw such a security warning. I deleted that container and created a container with a strong password.
Then I got the error after I've started a wrong container (so the connection failed because I was trying to provide the password for a different container). Since then, I prefer to use Kinematic to manage and access my containers. Before I type mssql -u sa -p mypassword in the Terminal and start to work, I just go to docker > Kinematic and Start my container.
In my case the container exited due to an insecure mssql password.
Try reading the container logs.
In my case, I just needed to start the container.
docker start {container_name}
In my case (I was following this tutorial https://database.guide/how-to-install-sql-server-on-a-mac/) the problem was the host address.
I was trying to connect to localhost and I got the ECONNREFUSED message but then I realized that I needed to use the local IP docker assigned to the container (it was something like 192.168.xxx.xxx), so:
mssql -s 192.168..... -o 1433 -u sa -p 'mypassword'
finally worded.
I had the same, in my case I notice that the problem was the PORT, so:
1)Check if the container is running with
docker start "container_name"
2)Then, get the correct PORT with:
docker ps
3) Run it
mssql -s "PORT" -o 1433 -u sa -p "pwd"
I'm adding this answer to complement Krzysztof Tomasz's answer.
I was following this guide: How to Install SQL Server on a Mac
Everything was going well but at the time of connecting to the container with this command:
mssql -u sa -p mypass1
I got:
Error: Failed to connect to localhost:1433 - connect ECONNREFUSED
127.0.0.1:1433
Then I opened Docker app, clicked the container and in the Logs menu I could see the following:
2020-02-05 16:26:45.71 spid20s ERROR: Unable to set system
administrator password: Password validation failed. The password does
not meet SQL Server password policy requirements because it is too
short. The password must be at least 8 characters..
The password I set had only 7 chars. :o)
Now this makes sense.
This is also documented # Microsoft doc here:
Quickstart: Run SQL Server container images with Docker
Solved this problem by removing the container and launching it again...
As I only had one container I ran the following command:
docker rm $(docker ps -a -q)
Then launched sql server image again with a stronger password:
docker run -d --name sql_server_demo -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=MyPass11' -p 1433:1433 microsoft/mssql-server-linux
I resolved this issue by updating the port from 1422 to 1433, I used Kitematic to implement this update.
I had the same, and it was a RAM issue, HOWEVER... 4GB didn't do it for me, for some reason in my case I needed 6, then it worked.
Make sure you have started the container in docker.
Command to start a container: docker start container "containerName"
and then try to connect mssql
I had same problem too, after study the logs with two commands:
docker ps -a
then
docker logs 99373f58f2ff
I understood that problem is related to the password dose not to meet SQL Server password policy! That's is.
I have a postgres database that I created through heroku. I am trying to access it through psql with the command:
cse-190-fortune matanvardi$ psql "dbname=dccemfsa6camml host=ec2-54-235-152-226.compute-1.amazonaws.com \
user=tfmfbqxqjznsbl password=********* port=5432 sslmode=require"
I get this error:
psql: could not connect to server: Operation timed out
Is the server running on host "ec2-54-235-152-226.compute-1.amazonaws.com" and accepting
TCP/IP connections on port 5432?
I've cloned the repository and I'm logged in, I simply cannot figure out what is wrong here. Any help would be greatly appreciated.
To access your Heroku database from the command line use the command:
heroku pg:psql
Edit:
I ran your command from my machine. If course I don't have your password but I got:
$ psql "dbname=dccemfsa6camml host=ec2-54-235-152-226.compute-1.amazonaws.com user=tfmfbqxqjznsbl port=5432 sslmode=require"
Password:
psql: FATAL: password authentication failed for user "tfmfbqxqjznsbl"
Which means I was able to connect, which is farther than you got. It must be a problem with your network setup.