rockmongo管理工具

tech2023-12-06  35

rockmongo管理工具

By default, MongoDB provides the interactive JavaScript-based mongo shell which can be used for performing database operations. Although this shell may be the best approach to start with MongoDB queries, a GUI tool to administer the service is always useful.

默认情况下,MongoDB提供基于交互式JavaScript的mongo shell,可用于执行数据库操作。 尽管此外壳可能是从MongoDB查询开始的最佳方法,但是用于管理服务的GUI工具始终很有用。

There are many such GUI tools available, like Rockmongo, PHPMoAdmin, Fang of Mango, UMongo, MongoExplorer, and MongoVUE, to name just a few. When it comes to using MongoDB with PHP-based projects, Rockmongo and PHPMoAdmin are good options. In this article, we’ll take a look at Rockmongo.

仅提供了一些这样的GUI工具,例如Rockmongo,PHPMoAdmin,Fang of Mango,UMongo,MongoExplorer和MongoVUE。 在将MongoDB与基于PHP的项目一起使用时,Rockmongo和PHPMoAdmin是不错的选择。 在本文中,我们将介绍Rockmongo。

Rockmongo is an open source MongoDB administration tool written in PHP5. You’ll become familiar with using Rockmongo to create databases, collections and documents, query collections, and import and export data. Ready?

Rockmongo是用PHP5编写的开源MongoDB管理工具。 您将熟悉使用Rockmongo创建数据库,集合和文档,查询集合以及导入和导出数据。 准备?

入门 (Getting Started)

The requirements for running Rockmongo are:

运行Rockmongo的要求是:

a web server running PHP

运行PHP的Web服务器 PHP 5.1.6 or higher with session support

PHP 5.1.6或更高版本,具有会话支持 the php_mongo extension for MongoDB

MongoDB的php_mongo扩展

Once you have the proper environment, go ahead and download the latest version of Rockmongo from its download page at rockmongo.com/downloads.

一旦你有适当的环境,继续前进,在距其下载页面下载最新版本的Rockmongo的rockmongo.com/downloads 。

Installation instructions can be found on the Rockmongo Wiki, but in general you’ll need to unzip the downloaded package in a web-accessible directory on your server root of your site and rename it to rockmongo. Open your web browser and access the index.php page from the location where you have installed Rockmongo.

安装说明可在Rockmongo Wiki上找到,但是通常,您需要将下载的软件包解压缩到站点服务器根目录上的Web可访问目录中,并将其重命名为rockmongo。 打开您的Web浏览器,然后从安装Rockmongo的位置访问index.php页面。

The default username and password is “admin” and “admin”. If you changed the password during installation, then enter the appropriate credentials. Click on “Login and Rock” and you’ll be redirected to the home page of the Rockmongo application.

默认的用户名和密码为“ admin”和“ admin”。 如果您在安装过程中更改了密码,请输入适当的凭据。 单击“ Login and Rock”,您将被重定向到Rockmongo应用程序的主页。

As you can see, the home page lists basic information about MongoDB Server location and connection, PHP Web Server and MongoDB settings. The left panel shows the list of databases and collections.

如您所见,主页列出了有关MongoDB Server位置和连接,PHP Web Server和MongoDB设置的基本信息。 左面板显示数据库和集合的列表。

创建数据库和集合 (Creating Databases and Collections)

The Databases tab lists all of the database available on the MongoDB server. To create a new database, click Create New Database on the Databases tab.

“数据库”选项卡列出了MongoDB服务器上所有可用的数据库。 若要创建新数据库,请在“数据库”选项卡上单击“创建新数据库”。

Then enter the name of the database and click Create (I’ll name mine “rockdb”). The newly created database will appear in the left panel.

然后输入数据库的名称,然后单击创建(我将其命名为“ rockdb”)。 新创建的数据库将出现在左侧面板中。

To create a new collection, click on Create under the new database in the left pane and provide the desired name for the collection (I’ll use “blog_collection”).

要创建新集合,请在左窗格中的新数据库下单击创建,并为集合提供所需的名称(我将使用“ blog_collection”)。

When you provide the collection information, don’t worry about the Is Capped field. It’s safe to leave it unchecked.

提供收集信息时,请不要担心“上限”字段。 取消选中是安全的。

The new collection will appear in the left panel under the database. You can click on the collection to list all of the documents in it. (Note that Mongo DB creates a default system.indexes collection when you create first collection in a database.)

新集合将显示在数据库下方的左侧面板中。 您可以单击集合以列出其中的所有文档。 (请注意,当您在数据库中创建第一个集合时,Mongo DB将创建一个默认的system.indexes集合。)

插入文件 (Inserting Documents)

To insert documents, click on the Insert tab and then the name of the collection.

要插入文档,请单击“插入”选项卡,然后单击集合名称。

We can specify the new document structure either as JSON or a PHP array. Choosing either format doesn’t make any difference to the document formed, it’s just a matter of comfort for developers.

我们可以将新文档结构指定为JSON或PHP数组。 选择任何一种格式都不会影响所形成的文档,对开发人员来说只是一个舒适的问题。

After specifying the document, click on Save. Similarly, go ahead and insert other documents.

指定文档后,单击“保存”。 同样,继续并插入其他文档。

To view the documents inside a collection, click on the collection in the left panel and you will see a list of all of the documents in the content area. The records most recently inserted will appear first.

要查看集合中的文档,请单击左侧面板中的集合,您将在内容区域中看到所有文档的列表。 最近插入的记录将首先出现。

更新,删除和复制文档 (Updating, Deleting, and Duplicating Documents)

You can update, delete or duplicate any document by clicking on the corresponding options provided on each document. Clicking on any of the links will take the document to edit mode where you can make changes in either JSON or PHP as you did earlier.

您可以通过单击每个文档上提供的相应选项来更新,删除或复制任何文档。 单击任何链接将使文档进入编辑模式,在该模式下,您可以像以前一样在JSON或PHP中进行更改。

查询文件 (Querying Documents)

Querying the database is one of the important functions of any database administration tool. Whenever you click on a collection, you will find a text area on the top of the page for running queries against it.

查询数据库是任何数据库管理工具的重要功能之一。 每当您单击一个集合时,您都会在页面顶部找到一个文本区域,以对它运行查询。

Like the documents, query expressions can also be specified either as JSON or a PHP array. There are three action options available in the drop down: findAll, remove, and modify.

与文档一样,查询表达式也可以指定为JSON或PHP数组。 下拉菜单中提供了三个操作选项:findAll,删除和修改。

findAll: This is the default option. Specify the find condition and click on Submit Query. The matching documents will appear in the search results.

findAll:这是默认选项。 指定查找条件,然后单击提交查询。 匹配的文档将出现在搜索结果中。

remove: This is similar to modify in that you just have to specify the condition for selecting documents, but the action removes the matching documents from the collection.

remove:这类似于修改,因为您只需指定选择文档的条件,但是该操作将从集合中删除匹配的文档。

modify: When you click on modify, you will see two text sections. The first section is to specify the condition for matching documents and the other is to specify the update script. This feature can be used to do bulk-updates.

修改:单击修改时,您将看到两个文本部分。 第一部分是指定匹配文档的条件,第二部分是指定更新脚本。 此功能可用于进行批量更新。

使用说明 (Using Explain)

This is one of the most useful features and probably the one I like the most in Rockmongo. The explain query is frequently used to analyze queries and their index usages. As shown below, you can specify your find query and then click on the Explain button. This will give all the cursor details for the query.

这是最有用的功能之一,可能是我在Rockmongo中最喜欢的功能。 说明查询通常用于分析查询及其索引用法。 如下所示,您可以指定查找查询,然后单击“解释”按钮。 这将提供查询的所有游标详细信息。

导入和导出数据库 (Importing and Exporting Databases)

Import and export features are useful for when you want to backup the database. The import/export functionality in Rockmongo does the same task as the mongoimport and mongoexport functions.

当您要备份数据库时,导入和导出功能很有用。 Rockmongo中的导入/导出功能执行与mongoimport和mongoexport功能相同的任务。

To export a database or collection, click the Export tab. Check all the checkboxes for the collections you want to export. Check the Download option as well, and then click on Export. It will give you a downloadable JavaScript file containing the entire exported database.

要导出数据库或集合,请单击“导出”选项卡。 选中您要导出的集合的所有复选框。 还要选中“下载”选项,然后单击“导出”。 它将为您提供一个包含整个导出数据库的可下载JavaScript文件。

To import the data in another database, go to that database and click on the Import tab. Choose the JS file you just downloaded, and the entire dataset will be imported to the database.

要将数据导入另一个数据库,请转到该数据库,然后单击“导入”选项卡。 选择您刚刚下载的JS文件,整个数据集将被导入数据库。

结论 (Conclusion)

There are a lot of other features in Rockmongo that I’m sure you’ll want to explore once you start working with it. In this article I’ve covered only the most frequently used features to help you get a head start with it. If you have any questions related to the article, feel free to post your comments!

Rockmongo中还有很多其他功能,一旦您开始使用它,我敢肯定您会想要探索的。 在本文中,我仅介绍了最常用的功能来帮助您快速入门。 如果您对本文有任何疑问,请随时发表您的评论!

Image via Fotolia

图片来自Fotolia

翻译自: https://www.sitepoint.com/rockmongo-for-php-powered-mongodb-administration/

rockmongo管理工具

相关资源:MongoDB管理工具RockMongo
最新回复(0)