mongodb关于启动权限的问题
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
问题
有时候我们会因为数据的问题(如备份mongodump, 恢复mongorestore)会重新修复数据库存
mongod --repair --dbpath=f:/dbpath
不过问题就来了,当你重启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
或者
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
等等,基本上都是说Permission denied的事。
解决
其实也很明险,主要还是权限的问题。
当你使用 “root”账号在 mongod上做一些文章的时候,生成的文件和目录都会是root的权限。
而当你用service mongodb start时,这个的启动并不是root账号,一般是mongodb账号,因而自然访问不了一些root的文件和文件夹了。
所以只要重新分配dbpath的权限即可:
sudo chown -R mkyong /data/db (自定义的data路径也可)

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

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

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

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.

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

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

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.

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.

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 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
