Home >Database >Mysql Tutorial >Introduction to mongodb server startup examples under dos
This article mainly introduces the relevant information about server startup and connection under windowmongodb under dos. Friends in need can refer to the following
1. Configuration environmentVariable
Add MongoDB’s installation directory (such as: D:\Program Files\mongodb\Server\3.4\bin) to path
2. Start the mongodb service (operate in dos, premise: the environment variables have been configured, if the environment variables are not configured, you need to enter the bin directory to operate)
(1) Start local Service
mongod.exe --dbpath mongodb的数据库路径 // 如:mongodb --dbpath D:\mongodb\db (“mongodb的数据库路径”是自定义目录)
Note: This command can meet the basic needs, that is, local self-test, and does not need to bind the IP address
(2) Commands related to service startup
--bind_ip 192.168.1.2 //绑定服务IP,若绑定127.0.0.1,则只能本机访问,不指定默认本地所有IP --logpath E:\MongoDB_Data\dbConf\mongodb.log // 定MongoDB日志文件,注意是指定文件不是目录 --logappend // 使用追加的方式写日志 --dbpath E:\MongoDB_Data\db // 指定数据库路径 --port 27017 // 指定服务端口号,默认端口27017 --service // 以服务方式启动 --serviceName //指定服务名称 --serviceDisplayName//
Specify the service name, execute when there are multiple mongodb services
For example:
> mongod.exe --bind_ip 192.168.1.2 --logpath E:\MongoDB_Data\dbConf\mongodb.log --logappend --dbpath E:\MongoDB_Data\db --port 27017 --service
(3) Client
A. Connect local Database
>mongo // 直接输入mongo命令即可
B. Connect to the remote database, without username and password
> mongo 远程服务器IP:端口port // 如:mongo 192.168.1.2:27017
C.
Connect to the remote database, with username and password
> mongo 远程服务器IP:端口port -u 用户名 -p 密码 // 如:mongo 192.168.1.2:27017 -u admin -p pwd123
The above is the detailed content of Introduction to mongodb server startup examples under dos. For more information, please follow other related articles on the PHP Chinese website!