I used mongodb version < 4. Now I needed to install mongodb on ubuntu 22, the easiest way was to install version 6.0.3
But now some of the functionality does not work, for example
db.listCollections()
-There were no problems, but after upgrading to mongodb6.0.3 - it does not work. I read that it is advised to use
db.getCollectionNames()
Are these functions interchangeable? Is there no difference between them?
And is it possible to make db.listCollections() work in version 6.0.3?
I read here that many functions are already outdated in version 5
db.listCollections() was a convenience wrapper in the legacy shell.
To get the same behavior in mongosh, use the listCollections database command, like
db.runCommand("listCollections")
Related
I'm trying to use VSCode Remote extension to connect to a remote host that runs on RHEL/CentOS 6, but it fails to connect since CentOS 6 ships with GLIBC 2.12 and GLIBCXX 3.4.1. As mentioned in this post, in order to get the extension to work, the workaround is to install GLIBC>=2.17 and GLIBCXX>=3.4.18.
Unfortunately, I don't have sudo access for the server, so I won't be able to update these libraries using the bash script provided in the link. Also, in this SO post, the author says not to update the system GLIBC since it can break down system applications. That being said, I've tried something different -- I extracted those rpm packages, as described in this blog, inside my home folder. I've then updated the env variables PATH and LD_LIBRARY_PATH in ~/.bash_profile to point to these new locations. But the node binary (in VS Code Remote) still can't find these libraries.
Is there a way to let the node binary know where to look for these libraries? More precisely, can someone explain how I can make this extension work without sudo access?
I've got it to work by installing gcc and glibc using Linuxbrew. See this post for more details: https://github.com/microsoft/vscode-remote-release/issues/103#issuecomment-546551293.
Couple of things to take note of:
Node binary versions in VS Code Server may vary between commits. In the GitHub comment above, the author uses node#10 -- you may replace it with node#12; everything would still work.
Make sure glibc and gcc are properly installed using linuxbrew. This step is key.
I'm running Ubuntu 16.04 LTS and I want to use Mongodb with PHP. For this I thought that sudo apt-get install php5-mongo (which is enough for Ubuntu 14.04 LTS) would be enough but I was wrong. I'm getting error like this E: Unable to locate package php5-mongo.
I've just upgraded to Ubuntu 16.04 LTS and want to use mongodb with PHP. Running PHP version is PHP Version 7.0.4-7ubuntu2.
So what can I do to solve this?
I'm afraid you are a bit out of luck at the moment. The current situation is that there are two MongoDB extensions:
"php-mongo", which is the "old" one; This extension supports up to PHP 5.*, but not PHP7. Only bug fixes are planned for it;
"php-mongodb", which is the "new" one; This extension supports PHP5 as well as PHP7;
Now the problem is that the new one is not compatible with the old one, as their whole internals are completely different. Unfortunately there are very few places where examples using the new one's syntax is used, as absolute majority of Mongo-related code is written using the old extension.
As it stands at the moment, if you have moved on to PHP7 your only option is to use the "new" extension, which in turn means that your previous code will stop working.
I've seen couple attempts to create a polyfill for making the migration those two possible (example: https://github.com/alcaeus/mongo-php-adapter), however as I haven't tried it myself I can't tell how well it works.
It seems that this library http://mongodb.github.io/mongo-php-library/ is supposed to cover the gap - after giving it a shot I believe it should cover majority of the "old" functionality without updating code too much.
If some of you are still wondering to use a simple wrapper to the new library as said in this answer: https://stackoverflow.com/a/48086676/2569789
I'm maintaining one for this purpose and you can find it here: https://github.com/ThomasSquall/PHP7MongoDriver
It covers just a few methods at the today's date but I'm going to improve it constantly and I hope would like to contribute too :)
Is there a way to use the Legacy Mongo PHP Driver from PECL with PHP7? Maybe unofficial fork with PHP7 support or compile/modification instruction...
There is an alternative if you really need to use any bundle or library with strong dependencies on php mongo legacy driver, it's called "alcaeus:mongo-php-adapter". It provides an ext-mongo library on top of mongo-php-library (sic).
https://github.com/alcaeus/mongo-php-adapter
If you face any problem with composer related with the absence of legacy driver (Famous message "The requested PHP extension ext-mongo * is missing") you can fix it adding that to composer.json
"provide": {
"ext-mongo": "1.6.12"
},
In this case may be you want to take a look to this thread (same situation but with heroku): https://github.com/alcaeus/mongo-php-adapter/issues/67
No, the legacy driver does not support PHP7. Here's the commit and the JIRA Ticket where this was officially finalized.
The new PHP MongoDB driver can be found in PECL here (or GitHub).
To install, just:
pecl channel-update pecl.php.net
pecl install mongodb
echo "extension=mongodb.so" >> `php --ini | grep "Loaded Configuration" | sed -e "s|.*:\s*||"`
The documentation for the new driver can be found here. I'd like to include a note from the documentation:
Ultimately, this extension is not intended to be used alone. Users should considering using this driver alongside one or more userland PHP libraries, such as mongo-php-library.
The new mongodb driver / PHP extension is a lot more low-level than the legacy mongo driver, and you are encouraged to use a higher-level library on top of the driver rather than using it directly in your code.
The Mongo PHP Library (releases) is the official high-level library for PHP, and it's what is recommended to use in your projects. It's still in Beta, but this still seems to be the safest and most-future-proof path forward with PHP7.
Edit: The Legacy Mongo Driver is no longer active at all.
I am trying to install mongo_fdw on Ubuntu but I am getting some compilation errors. I have installed mongodb, postgresql 9.1, postgresql-server-dev and libpq-dev using apt-get.
I have updated the $PATH as instructed, cd to the directory with the mongo_fdw sources and typed make.
The code starts compiling but then I get errors (some objects and methods aren't found). What am I missing?
It's possible that the extension you're using expects the 9.2 version of the foreign data wrapper API, which has read/write support. Without details like exact errors it's impossible to say for sure.
I have GNU R installed (the S-like statistics package; version 2.8.1) and PostgreSQL (8.4.1), but I cannot connect GNU R to my RDBMS.
When I first did this (years ago - code lost) DBI for R didn't exist. Now it does. I am also confused as to which R package to use. A quick search returns:
RPostgreSQL seems to be the most up-to-date
RPgSQL Looks abandoned. I wish they would put a date on their webpage. ;-(
My Linux distribution doesn't package R packages (irony) but I am comfortable running R CMD INSTALL package.tar.gz.
I installed RPostgreSQL: a lot of documentation says to call dbConnect but I get the following error message: Error: object "dbConnect" not found.
Just for completeness, you have two more options
RODBC which is very mature and feature-complete but doesn't correspond to the DBI framework as the PostgreSQL, MySQL, SQLite, Oracle, ... interfaces do. You also need to fiddle with ODBC setup files which can be tricky. But ODBC may be useful for other data access uses too.
RdbiPgSQL from the BioConductor project which is also mature but uses yet another protocol that was to compete with DBI and never took of. This PostgreSQL package is featureful though.
But as a RPostgreSQL maintainer/co-author I am glad you found this one. As the other poster suggested, try library(RPostgreSQL) before issueing commands. If you encounter other problems, feel free to email me off-SO with a bug report.
Edit: There is another option of embedding R inside PostgreSQL using Joe Conway's PL/R.
Maybe you need to run require(RPostgreSQL) before you can use dbConnect?
My guess is you need to install the DBI package (most database packages depend on it).
If you use install.packages('RPpostgreSQL',dep=TRUE) from within R it should take care of any dependency issues.
RODBC works great for me. You just have to set up a data source name (DSN) for the database you want to connect to. I find this nice because then the specific connection info does not have to be stored in R, and it may vary for your collaborators.
Also, yes, it sounds like you haven't loaded the RPostgresSQL package.