前言

和MySQL数据库相比MongoDB的管理工具其实不算多,除了MongoVUE客户端以外想要通过类似phpMyAdmin一样通过Web管理MongoDB的数据库应该也只剩下RockMongo了。

和phpMyAdmin一样好用的MongoDB管理工具


更新记录

2015年10月05日 - 初稿

阅读原文 - https://wsgzao.github.io/post/rockmongo/

扩展阅读

MongoDB - https://www.mongodb.org/
RockMongo - http://rockmongo.com/


PHP环境支持

LTMP手动编译安装以及全自动化部署实践 - https://wsgzao.github.io/post/ltmp/

部署RockMongo

mongo-php-driver

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#下载驱动
https://pecl.php.net/package/mongo
https://github.com/mongodb/mongo-php-driver/

#phpize
/app/local/php/bin/phpize
#./configure
./configure --with-php-config=/app/local/php/bin/php-config
make && make install

#编辑php.ini
extension=mongo.so

#重启php-fpm
kill -USR2 `cat /app/local/php/var/run/php-fpm.pid`

#检查phpinfo
echo "<?php phpinfo(); ?>" > /app/data/test/phpinfo.php

配置RockMongo

修改config.php,注意mongo_auth和control_auth的配置关系

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?php
/**
* RockMongo configuration
*
* Defining default options and server configuration
* @package rockmongo
*/

$MONGO = array();
$MONGO["features"]["log_query"] = "on";//log queries
$MONGO["features"]["theme"] = "default";//theme
$MONGO["features"]["plugins"] = "on";//plugins

$i = 0;

/**
* Configuration of MongoDB servers
*
* @see more details at http://rockmongo.com/wiki/configuration?lang=en_us
*/
$MONGO["servers"][$i]["mongo_name"] = "mongodb ";//mongo server name
//$MONGO["servers"][$i]["mongo_sock"] = "/var/run/mongo.sock";//mongo socket path (instead of host and port)
$MONGO["servers"][$i]["mongo_host"] = "192.168.1.199";//mongo host
$MONGO["servers"][$i]["mongo_port"] = "27017";//mongo port
$MONGO["servers"][$i]["mongo_timeout"] = 0;//mongo connection timeout
//$MONGO["servers"][$i]["mongo_db"] = "MONGO_DATABASE";//default mongo db to connect, works only if mongo_auth=false
//$MONGO["servers"][$i]["mongo_user"] = "MONGO_USERNAME";//mongo authentication user name, works only if mongo_auth=false
//$MONGO["servers"][$i]["mongo_pass"] = "MONGO_PASSWORD";//mongo authentication password, works only if mongo_auth=false
$MONGO["servers"][$i]["mongo_auth"] = true;//enable mongo authentication?

$MONGO["servers"][$i]["control_auth"] = false;//enable control users, works only if mongo_auth=false
$MONGO["servers"][$i]["control_users"]["admin"] = "admin";//one of control users ["USERNAME"]=PASSWORD, works only if mongo_auth=false

$MONGO["servers"][$i]["ui_only_dbs"] = "";//databases to display
$MONGO["servers"][$i]["ui_hide_dbs"] = "";//databases to hide
$MONGO["servers"][$i]["ui_hide_collections"] = "";//collections to hide
$MONGO["servers"][$i]["ui_hide_system_collections"] = false;//whether hide the system collections

//$MONGO["servers"][$i]["docs_nature_order"] = false;//whether show documents by nature order, default is by _id field
//$MONGO["servers"][$i]["docs_render"] = "default";//document highlight render, can be "default" or "plain"

$i ++;

/**
* mini configuration for another mongo server
*/
/**
$MONGO["servers"][$i]["mongo_name"] = "Localhost2";
$MONGO["servers"][$i]["mongo_host"] = "127.0.0.1";
$MONGO["servers"][$i]["mongo_port"] = "27017";
$MONGO["servers"][$i]["control_users"]["admin"] = "password";
$i ++;
**/

?>

使用客户端连接

mongodb-linux

选择Linux 64-bit legacy
https://www.mongodb.org/downloads#linux

解压后可以直接执行二进制文件连接数据库

 ./mongo ip:port/admin -u root -p root

MongoVUE

MongoVUE管理MongoDB的Gui客户端工具,非常方便

http://www.mongovue.com/downloads/

打包下载

我把自己实践的介质都打包放在百度云中

1
2
3
4
5
6
file://E:\MongoDB     (0 folders, 4 files, 56.74 MB, 56.74 MB in total.)
mongo-php-driver-master.zip 1.45 MB
mongodb-linux-x86_64-3.0.4.tgz 38.41 MB
MongoVUE.zip 16.56 MB
rockmongo.zip 324.67 KB

http://pan.baidu.com/s/1kTvhGyz

文章目录
  1. 1. 前言
  2. 2. 更新记录
  3. 3. PHP环境支持
  4. 4. 部署RockMongo
    1. 4.1. mongo-php-driver
    2. 4.2. 配置RockMongo
  5. 5. 使用客户端连接
    1. 5.1. mongodb-linux
    2. 5.2. MongoVUE
  6. 6. 打包下载