跳至
[1]
[全屏预览]
#mongodb 安装到/usr/local 目录 cd /usr/local #获取并下载最新稳定版本 https://www.mongodb.com/download-center?jmp=nav #百度云盘 http://pan.baidu.com/s/1i47YB0T wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-3.2.8.tgz tar zxvf mongodb-linux-x86_64-3.2.8.tgz mv mongodb-linux-x86_64-3.2.8 mongodb cd mongodb mkdir db mkdir logs cd bin #新建配置文件 vi mongodb.conf #复制下面的配置文件 dbpath=/usr/local/mongodb/db logpath=/usr/local/mongodb/logs/mongodb.log pidfilepath=/usr/local/mongodb/mongo.pid fork=true logappend=true shardsvr=true auth=true port=27017 nohttpinterface=true #结束 #重新绑定mongodb的配置文件地址和访问IP /usr/local/mongodb/bin/mongod --bind_ip localhost -f /usr/local/mongodb/bin/mongodb.conf #添加服务mongodb /usr/local/mongodb/bin/mongod show dbs #列出所有数据库 use admin #切换到admin数据库,添加的账号才是管理员账号。 show collections db.system.users.find() db.createUser({user:"root",pwd:"123456",roles:[{role:"root",db:"admin"}]}) #添加管理员账号:root 密码:123456 权限:有数据库admin的所有操作权限 db.auth('root','123456') #添加管理员用户认证,认证之后才能管理所有数据库 exit #退出 vi /etc/rc.d/init.d/mongod #设置开机启动MongoDB #!/bin/sh # chkconfig: - 64 36 # description:mongod case $1 in start) /usr/local/mongodb/bin/mongod --maxConns 20000 --config /usr/local/mongodb/bin/mongodb.conf ;; stop) /usr/local/mongodb/bin/mongo localhost:27017/admin --eval "db.auth('root', '123456');db.shutdownServer()" ;; status) /usr/local/mongodb/bin/mongo localhost:27017/admin --eval "db.auth('root', '123456');db.stats()" ;; esac chmod +x /etc/rc.d/init.d/mongod #添加脚本执行权限 chkconfig mongod on #设置开机启动 service mongod stop #关闭MongoDB service mongod start #启动MongoDB #重启一下系统测试下能不能自启 #进入mongodb的shell模式 /usr/local/mongodb/bin/mongo #查看数据库列表 show dbs #当前db版本 db.version(); #安装mongodb完成。 #开始安装 mongodb php扩展 #获取最新扩展插件 https://pecl.php.net/package/mongodb #下载最新版本 cd /www/wdlinux/php wget https://pecl.php.net/get/mongodb-1.1.8.tgz #解压 tar zxvf mongodb-1.1.8.tgz cd ./mongodb-1.1.8 /www/wdlinux/php/bin/phpize #编译 make #安装 make install #修改php.ini [mongodb] extension=mongodb.so #完成 访问 phpinfo.php <?php phpinfo(); ?>
2. [图片] mmm.png

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article
Assassin's Creed Shadows: Seashell Riddle Solution
1 months agoByDDD
What's New in Windows 11 KB5054979 & How to Fix Update Issues
3 weeks agoByDDD
Where to find the Crane Control Keycard in Atomfall
1 months agoByDDD
How to fix KB5055523 fails to install in Windows 11?
2 weeks agoByDDD
InZoi: How To Apply To School And University
3 weeks agoByDDD

Hot Tools

SublimeText3 English version
Recommended: Win version, supports code prompts!

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

SublimeText3 Chinese version
Chinese version, very easy to use

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function
