Table of Contents
mongodb在ubuntu的安装
问题
解决
Home Database Mysql Tutorial mongodb关于启动权限的问题

mongodb关于启动权限的问题

Jun 07, 2016 pm 03:54 PM
mongodb about start up Permissions question

mongodb在ubuntu的安装 安装完成,在/etc/mongodb.conf配置自己的 dbpath,logpath等,即可指定到路径。 然后即可使用service来启动mongo数据库: service mongodb start/stop service的默认权限是 mongodb 用户,一般不是root用户 问题 有时候我们会因为数

mongodb在ubuntu的安装

安装完成,在/etc/mongodb.conf配置自己的 dbpath,logpath等,即可指定到路径。

然后即可使用service来启动mongo数据库:

service mongodb start/stop
Copy after login
service的默认权限是mongodb用户,一般不是root用户

问题

有时候我们会因为数据的问题(如备份mongodump, 恢复mongorestore)会重新修复数据库存

mongod --repair --dbpath=f:/dbpath
Copy after login
这个时候就要注意你所使用的权限了,一般会是root用户。

不过问题就来了,当你重启mongodb的时候,发现启动不了,log日志报出的是:

Fri Mar 28 13:05:01 [initandlisten] exception in initAndListen: 10309 Unable to create/open lock file: 
/opt/mongo/data/mongod.lock errno:13 Permission denied
Copy after login

或者

warning couldn't write to / rename file /data/db/journal/prealloc.0: couldn't open file 
/opt/mongo/data/journal/prealloc.0 for writing errno:13 Permission denied 
Fri Mar 28 13:09:59 [initandlisten] exception in initAndListen: 13516 couldn't open file 
/opt/mongo/data/journal/j._0 for writing errno:13 Permission denied, terminating
Copy after login

等等,基本上都是说Permission denied的事。

解决

其实也很明险,主要还是权限的问题。

当你使用 “root”账号在 mongod上做一些文章的时候,生成的文件和目录都会是root的权限。

而当你用service mongodb start时,这个的启动并不是root账号,一般是mongodb账号,因而自然访问不了一些root的文件和文件夹了。

所以只要重新分配dbpath的权限即可:

sudo chown -R mkyong /data/db (自定义的data路径也可)
Copy after login
Statement of this Website
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

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Enable root permissions with one click (quickly obtain root permissions) Enable root permissions with one click (quickly obtain root permissions) Jun 02, 2024 pm 05:32 PM

It allows users to perform more in-depth operations and customization of the system. Root permission is an administrator permission in the Android system. Obtaining root privileges usually requires a series of tedious steps, which may not be very friendly to ordinary users, however. By enabling root permissions with one click, this article will introduce a simple and effective method to help users easily obtain system permissions. Understand the importance and risks of root permissions and have greater freedom. Root permissions allow users to fully control the mobile phone system. Strengthen security controls, customize themes, and users can delete pre-installed applications. For example, accidentally deleting system files causing system crashes, excessive use of root privileges, and inadvertent installation of malware are also risky, however. Before using root privileges

Which version is generally used for mongodb? Which version is generally used for mongodb? Apr 07, 2024 pm 05:48 PM

It is recommended to use the latest version of MongoDB (currently 5.0) as it provides the latest features and improvements. When selecting a version, you need to consider functional requirements, compatibility, stability, and community support. For example, the latest version has features such as transactions and aggregation pipeline optimization. Make sure the version is compatible with the application. For production environments, choose the long-term support version. The latest version has more active community support.

What should I do if wps cannot start the source application of this object? What should I do if wps cannot start the source application of this object? Mar 13, 2024 pm 09:13 PM

WPS is a very widely used office software, including documents, forms and PPT, and supports multi-terminal synchronization. If the prompt "The source application for this object cannot be launched" appears when editing wps, how to solve it? This problem may occur because you are trying to open a link or file, but its source application no longer exists or has been deleted. Here are some fixes: 1. Reinstall WPS software: Try reinstalling WPSOffice to fix the problem and make sure you are using the latest version. 2. Manually change the default program: Try to change the default program to WPS. You can right-click the file you want to open, select "Open with", and then

Which one to choose when starting wallpaperengine? Which one to choose when starting wallpaperengine? Mar 19, 2024 am 08:49 AM

When wallpaperengine starts, there are 4 different options. Many users don't know which one to choose when starting wallpaperengine. Generally, when wallpaperengine starts, choose the first one: start 32-bit. Which one to choose when starting wallpaperengine? Answer: Start 32-bit. 1. Generally, when wallpaperengine starts, select the first one: start 32-bit. 2. When wallpaperengine starts, there are 4 different options: start 32-bit; start 64-bit. 3. Start 32-bit: This is a generally recommended option and suitable for most users. 4. Start 64-bit: If the system supports 64-bit, you can choose this option

The difference between nodejs and vuejs The difference between nodejs and vuejs Apr 21, 2024 am 04:17 AM

Node.js is a server-side JavaScript runtime, while Vue.js is a client-side JavaScript framework for creating interactive user interfaces. Node.js is used for server-side development, such as back-end service API development and data processing, while Vue.js is used for client-side development, such as single-page applications and responsive user interfaces.

Where is the database created by mongodb? Where is the database created by mongodb? Apr 07, 2024 pm 05:39 PM

The data of the MongoDB database is stored in the specified data directory, which can be located in the local file system, network file system or cloud storage. The specific location is as follows: Local file system: The default path is Linux/macOS:/data/db, Windows: C:\data\db. Network file system: The path depends on the file system. Cloud Storage: The path is determined by the cloud storage provider.

What are the advantages of mongodb database What are the advantages of mongodb database Apr 07, 2024 pm 05:21 PM

The MongoDB database is known for its flexibility, scalability, and high performance. Its advantages include: a document data model that allows data to be stored in a flexible and unstructured way. Horizontal scalability to multiple servers via sharding. Query flexibility, supporting complex queries and aggregation operations. Data replication and fault tolerance ensure data redundancy and high availability. JSON support for easy integration with front-end applications. High performance for fast response even when processing large amounts of data. Open source, customizable and free to use.

Discuz Forum Permission Management: Read Permission Setting Guide Discuz Forum Permission Management: Read Permission Setting Guide Mar 10, 2024 pm 05:33 PM

Discuz forum permission management: Read the permission setting guide In Discuz forum management, permission setting is a crucial part. Among them, the setting of reading permissions is particularly important, as it determines the scope of content that different users can see in the forum. This article will introduce in detail the reading permission settings of the Discuz forum and how to flexibly configure it for different needs. 1. Basic concepts of reading permissions In the Discuz forum, reading permissions mainly include the following concepts that need to be understood: Default reading permissions: Default after new user registration

See all articles