是否有任何Linux mysql命令行工具不需要安装整个mysql数据库安装包?
我要做的是从服务器#1(应用服务器),执行将在服务器#2(数据库服务器)上执行的mysql命令.我不想在本地服务器上运行db或安装完整的mysql db.
我正在运行mongo 1.8.2并试图看看如何在Mac上干净利落地关闭它.
在我们的ubuntu服务器上,我可以从mongo shell干净地关闭mongo:
> use admin
> db.shutdownServer()
Run Code Online (Sandbox Code Playgroud)
但在我的Mac上,它并没有杀死mongod进程.输出显示它'应该'关闭但是当我ps -ef |时 grep mongo它向我展示了一个活跃的过程.另外,我仍然可以打开一个mongo shell并查询我的dbs,就像它从未关闭一样.
我的db.shutdownServer()本地输出是:
MongoDB shell version: 1.8.2
connecting to: test
> use admin
switched to db admin
> db.shutdownServer()
Tue Dec 13 11:44:21 DBClientCursor::init call() failed
Tue Dec 13 11:44:21 query failed : admin.$cmd { shutdown: 1.0 } to: 127.0.0.1
server should be down...
Tue Dec 13 11:44:21 trying reconnect to 127.0.0.1
Tue Dec 13 11:44:21 reconnect 127.0.0.1 failed couldn't connect to server 127.0.0.1
Tue Dec 13 …Run Code Online (Sandbox Code Playgroud) 我正在使用Mongo shell来查询我的Mongo数据库.我想使用ObjectID中包含的时间戳作为我的查询的一部分,也作为一个列提取到输出中.我已经设置了Mongo来自己创建ObjectID.
我的问题是我无法找到如何使用ObjectID来提取其时间戳.
以下是我试图开始工作的查询.'createdDate'字段是占位符; 不确定正确的字段是什么:
//Find everything created since 1/1/2011
db.myCollection.find({date: {$gt: new Date(2011,1,1)}});
//Find everything and return their createdDates
db.myCollection.find({},{createdDate:1});
Run Code Online (Sandbox Code Playgroud) 我已经在这几个小时了,并没有发现任何人已经得到这个工作了.我想在Mongo中保留一个BigDecimal对象,但是Mongo本身并不支持BigDecimal.我在这里跟随Spring的文档,但没有运气.
据我所知,Spring在写入数据库时没有将自定义转换器类注入Mongo.这就是我所做的:
我的applicationContext-services.xml ...
<!-- Factory bean that creates the Mongo instance -->
<mongo:mongo
host="localhost"
port="1234" />
<mongo:db-factory
dbname="solar"
mongo-ref="mongo"/>
<mongo:mapping-converter>
<mongo:custom-converters>
<mongo:converter>
<bean class="com.mine.BigDecimalReadConverter"/>
</mongo:converter>
<mongo:converter>
<bean class="com.mine..BigDecimalWriteConverter"/>
</mongo:converter>
</mongo:custom-converters>
</mongo:mapping-converter>
<!-- Use this post processor to translate any MongoExceptions thrown in @Repository annotated classes -->
<bean class="org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor"/>
<bean id="mongoDbTest"
class="com.mine.MongoDbTest">
<property name="mongoTemplate">
<ref local="mongoTemplate" />
</property>
</bean>
Run Code Online (Sandbox Code Playgroud)
我得到的错误是:
java.lang.IllegalArgumentException: Multiple constructors with arguments found in class java.math.BigDecimal! Annotate one with @PreferedConstructor explicitly to select …Run Code Online (Sandbox Code Playgroud) 我在Mongo做空间查询.我需要找到旧金山10英里范围内的所有场地.从命令行开始,当使用$ geoNear(works)vs $ near(不起作用)时,我会得到不同的结果.我需要使用$ near因为我正在使用Mongoose并且它使用$ near.
$ geoNear有效.我运行这个命令:
db.runCommand({geoNear:"venues",near:[-122.418,37.775], maxDistance:10/69});
Run Code Online (Sandbox Code Playgroud)
我得到的结果按距离排序,在半径10英里范围内.大.
但后来我运行这个$ near命令,我得不到任何结果:
db.venues.find({loc: {$near: [-122.418,37.775] }, $maxDistance:10/69})
Run Code Online (Sandbox Code Playgroud)
据我所知,他们是同一个命令.我错过了什么吗?如果我删除$ maxDistance,我会得到结果,并且它们按距离正确排序.但是,我也得到了超过10英里的结果.
db.venues.find({loc: {$near: [-122.418,37.77] }})
Run Code Online (Sandbox Code Playgroud)