I have a local mongodb 4.0 instance running with a collection called test^3.0 under patternbuilder database.
I'm trying to export the content of the collection to a json file to be migrated to another server instance.
I've downloaded Mongo Database Tools version 4.0.
When running on the local server the following command:
mongoexport --db patternbuilder --collection test^3.0
I get the following response:
2021-04-27T20:51:40.018+0300 connected to: mongodb://localhost/
2021-04-27T20:51:40.172+0300 exported 0 records
No matter what I tried on the command line switches - I still get 0 records exported.
Here is a snapshot of the local host server from Robot 3T
Why?
Ok. Found the issue...
As I am on a windows machine, the ^ char is invalid in the command line.
So running the below works just fine.
mongoexport --db patternbuilder --collection "test^3.0"
Thanks
Related
I'm trying to run two MonetDB databases simoultaneously in Windows.
I changed the database name in M5server.bat to mydb, and added -database=mydb to mclient.bat
Then I copied the M5server.bat file and changed the farm to mydb2. I also copied the mclient.bat file and added -database=mydb2.
I run the two server bats to start the two databases and that seems to work fine (no errors).
Then I run the first mclient.bat and it connects to the server with no issues.
But when I run the copied mclient.bat and try to connect using user/password monetdb/monetdb, I get the following error and cannot connect:
request for database 'mydb2', but this is database 'mydb', did
you mean to connect to monetdbd instead?
How to run two databases simoultaneously in Windows? How to connect to two databases at the same time?
You should use different ports for different databases:
Example db1:
mserver5.bat file
--set "mapi_port=50001"
mclient.bat file
-p 50001
Example db2:
mserver5.bat file
--set "mapi_port=50002"
mclient.bat file
-p 50002
Please, I need help with my postgres server. I have problems starting the server. I was using the app here a few months ago and everything was fine. Today I spent hours trying to start it yet couldn't. I then realised I had another instance of PostgreSQL installed. I uninstalled version 9.6 blocking my app.
Now after trying again, the PostgreSQL app throws the error when I use psql:
FATAL: role "username" does not exist
I didn't set the role or user but it somehow took my username and is throwing does not exist. Please, how do I start my server. I have seen someone with a similar issue here but unlike in his case, I didn't even get to start the server. not to speak of deleting the database. Please, how do I address this? Any help would be appreciated.
I also noticed he was able to execute
which psql
which returned his supposed psql path. It does not return anything in my case. Not sure how the configuration works, this is my second time using this database and it failed right away.
Thank you for your time, as answered in one of the SO question here. Running
sudo -u postgres -i
did give me access to postgres, but if you are using the postgres app like myself here . Running psql commands would not work for you as postgres is not installed globally on your machine. But running
'/Applications/Postgres.app/Contents/Versions/9.5/bin'/psql -p5432
which is the exact command the postgres app execute when you attempt to start the service works great and start the service for me. You can then proceed and add the role and database your postgres app looks for by default. So in summary. Below is what worked for me.
$sudo -u postgres -i
$'/Applications/Postgres.app/Contents/Versions/9.*/bin'/psql -p5432
#CREATE USER postgres SUPERUSER;
#CREATE DATABASE postgres WITH OWNER postgres;
I'm trying to connect to a db2 server from my Laravel application. Since Laravel doesn't support db2 out of the box, I tried using this package https://github.com/cooperl22/laravel-db2, which requires me to install odbc driver.
So far, I've been able to install odbc using the following command:
apt-get install php-odbc
However, it seems like my /etc/odbc.ini and /etc/odbcinst.ini configuration are still wrong. and here's the full error message when I tried to run php artisan migrate:
[PDOException]
SQLSTATE[IM002] SQLDriverConnect: 0 [unixODBC][Driver Manager]Data source name not found, and no default
driver specified
Here's my /etc/odbc.ini:
[db2]
Description=DB2 Server
Driver=db2
Database=mydb
and here's my /etc/odbcisnt.ini:
[db2]
Description = DB2 database access
Driver = /opt/ibm/db2/V10.5/lib64/libdb2.so
FileUsage = 1
DontDLClose = 1
Ensure that your environment variables are set correctly. As shown on this link, make sure the following is set:
export DB2INSTANCE=db2inst1
isql -v sample db2inst1 ibmdb2
Exerpt from the unixodbc.org page I linked to above:
Then when it comes to connecting, you MUST have the environment
variable DB2INSTANCE set to a vaild db2 instance, so for instance to
connect with isql
Both of your config files look correct to me. (The isql part was just an example to test connectivity.)
I'm running boot2docker on OSX 10.10. I have a database container set up so my databases don't get reset every time I start/stop a container. I would like to import a dump of a postgres database from heroku into my docker database. Is this possible to do?
I ended up finding this out with the help of a coworker. It's a little bit harder than just a regular old postgres database, but not much. This is based off this stackoverflow answer.
Generate your heroku database dump download url: heroku pgbackups:url
Start a bash shell on your postgres container. On my system this container was named pg: fig run db bash
Install curl: apt-get update && apt-get install curl
Download the database dump using curl: curl -o latest.dump [PASTE THE OUTPUT OF STEP 1 HERE]
Import the dump (note, database name and username can be found in fig.yml and database.yml respectively): pg_restore --verbose --clean --no-acl --no-owner -h [YOUR BOOT2DOCKER IP] -U [YOUR_USERNAME] -d [DATABASE_NAME] latest.dump
And there you have it!
If the last step fails with some kind of invalid database error, double check latest.dump with head latest.dump. If you feel like your database is not downloading correctly, you may want to manually download it via the web gui and upload it to another host, like drop box. Then you would substitute step 1 with whatever url your dump can be found at.
The error in its entirety reads:
psql: could not connect to server: No such file or directory. Is the
server running locally and accepting connections on Unix domain socket
"/tmp/.s.PGSQL.5432"?
This is my second time setting up Postgresql via Homebrew on my Mac, and I have no clue what is going on. Previously, it had been working. At some point, I must've entered a command that messed things up. I'm not sure. Now, whenever I enter a SQL command from the command line, I receive the above message. I've run a command to check whether the server is running, and it apparently is not. If I attempt to start the server using
$ postgres -D /usr/local/pgsql/data
I receive the following error:
postgres cannot access the server configuration file
"/usr/local/pgsql/data/postgresql.conf": No such file or directory
I've uninstalled and reinstalled Postgresql via Homebrew, but the problem persists. I'm completely at a loss as to how to get this working. Any help would be appreciated.
your data directory is most likely wrong.
issue a "sudo find / -name "postgresql.conf" " on your terminal to see where your postgres file resides. Then, do an ls in the data directory. Use that in the -D option when starting postgres.