im trying to make a dump of all tables and schemes of an postgres docker container with the following command:
docker exec -i 3d7de2fb2d7a -u admin pg_dumpall > dumptest.sql
this creates a dumptest.sql file which should contain everything.
The restore process looks like this:+
cat .\dumptest_neu.sql | docker exec -i bec713662fb6 psql -U admin
The Problem: After I have executed the command I get the following error message:
invalid command \":
ERROR: syntax error at or near "OCI"
LINE 1: OCI runtime exec failed: exec failed: container_linux.go:349...
^
After doing some research, I found out that I need to add a /bin/bash to the command:
cat .\dumptest_neu.sql | docker exec -i 7f75d4c0c9e3 /bin/bash psql -U admin
And then I get the following message:
/usr/bin/psql: line 19: use: command not found
/usr/bin/psql: line 20: use: command not found
/usr/bin/psql: line 21: use: command not found
/usr/bin/psql: line 22: use: command not found
/usr/bin/psql: psql: line 24: syntax error near unexpected token `$version,'
/usr/bin/psql: psql: line 24: `my ($version, $cluster);'
Please help me im just trying to make a dump of everything in this postgres container.
This does not help beacause I have to dump all tables at once.
Related
I am trying to import a .sql file into my new created database. I used
docker exec -it <idOfContainer> psql -U <user> <database_name>
to specify the database I want to use. Then I tried to import the .sql file to the database using the command
psql <databasename> -f "<path/to/file.sql>";
but this error appears
ERROR: syntax error at or near "psql"
LINE 1: psql <databasename> -f "<path/to/file.sql>";
^
I am new in using postgres and databases, so no idea what to do, thanks for the help!
Your docker exec is wrong, you only need the '-i'
The -it executes tty which will get you to run into your container.
Importing databases can be done outside the container.
cat database.sql | docker exec -i <dockercontainername> psql -U <user> <databasename>
I'm trying export my results using xp_cmdshell but I recive this error :
"Sqlcmd: error: error while opening or using file (my_path)".
This is what I've wrote on sqlserver:
exec xp_cmdshell 'sqlcmd -S my_server -d my_db -E -Q "my_query" -s "," -o "my_path"'.
I've tried using command line and on it my instructions works.
I think its can be an permissions trouble but I'm new on this type of things and I can't solve by myself. I hope that some of you can help me, thanks
this is my first question here because i really don't know what to do.
So i got a Database named mydatabase.
I also got a Collection named mycollection.
And i got a Backup-File named backup.bson.gz.
I want to use a command in MongoDB / Robo 3T that restores the backup file onto the database.
Because of that i tried the mongorestore command but i get the error:
Error: Line 1: Unexpected identifier
I wrote the command as shown in the title.
Thank you in advance!
use flag --drop
mongorestore -d mydatabase -c mycollections C:\Users\backup.bson.gz --drop
I've been trying to run an MSSQL script on my docker and it always fails... is my syntax wrong or something... I've looked this post but it doesn't work
Executing SQL scripts on docker container
docker exec mssql '/opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P gitgood12345 -q </CRE.sql'
this returned an error
rpc error: code = 2 desc = oci runtime error: exec failed: container_linux.go:262: starting container process caused "exec: \"/opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P ************** -q </CRE.sql\": stat /opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P AucMa1633485 -q </CRE.sql: no such file or directory"
I also tried something like this...
sudo docker exec -it mssql /opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P 'gitgood12345' -q </CRE.sql
The command returns me this error, which I'm not sure why....
Sqlcmd: '-q': Missing argument. Enter '-?' for help.
Please help me... the second method used to work, I think I forget a parameter or something...
The sqlcmd -q option requires an argument of the command you want to run. As your example is piping commands in on standard input, try without the -q.
docker exec mssql /opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P gitgood12345 < /CRE.sql
Quoting everything results in the container trying to execute a binary named "/opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P gitgood12345 -q </CRE.sql" which doesn't exist.
I'm trying to connect to my SQL Server from a Linux terminal using SQSH. The line is:
sqsh -S <ip address> -U <DOMAIN\user>
which throws an error:
Msg 18456, Level 14, State 1 Server 'DC2', Line 1
Login failed for user ''.
Notice that it seems to have removed the '\' which separates my domain and user.
On the server side, my event log confirms the same thing. The event reads:
Login failed for user 'DOMAINuser'.
Reason: Could not find a login matching the name provided.
I've tried using single and double quotation marks to encapsulate the domain and user name, but when I do that, the request does not even make it to the server, probably because the quotes signify something else syntactically.
Does anyone know what I'm doing wrong?
sqsh uses the FreeTDS configuration file by default, so the version of TDS can be specified. A full description can be found here, but the command line result should look like this:
sqsh -S<config file name> -D <database name> -U <domain>\\<user> -P <password / hash>
Example:
sqsh -S mssql -D MyDB -U DOMAIN\\testuser -P MyTestingClearPassword1