![](/style/images/good.png)
![](/style/images/bad.png)
使用 RockMongo 管理 MongoDB
source link: https://wsgzao.github.io/post/rockmongo/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
和 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
# 下载驱动
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 的配置关系
<?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/
我把自己实践的介质都打包放在百度云中
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
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK