Unable to start mongodb from vscode terminal - node.js

I'm learning nodeJS and started it up fine yesterday, yet today when I tried to do it, it just reports the following error:
Unable to create/open the lock file: "C:\Users\User\Documents\MongoDB\bin\mongod.exe\mongod.lock" (The system cannot find the path specified.)
Ensure the user executing mongod is the owner of the lock file and has the appropriate permissions. Also make sure that another mongod instance is not already running..."
After reporting the error it just shuts down. I installed it not via the msi file, but by extracting the zip archive.
The mongodb data folder is empty for some reason, and no service of mongodb is running in windows services. My account is the administrator too.

clarification sought, Is your mongo DB instance setup correctly.
I mean are you able to run command mongo from command prompt. Please give some details if you are able to run a query on mongo standalone host.
note, you need to have data and log directory before you can run mongodb services.

Related

Access database from an application hosted on IIS

The error I get is:
Cannot open database "DBNAME" requested by the login. The login failed.\r\nLogin failed for user 'IIS APPPOOL\DefaultAppPool'
Initial connection string is as follows, further in the question I'll only be using only a part of it.
Data Source=(localdb)\\MSSQLLocalDB;Initial Catalog=DBNAME;Integrated Security=True;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False;
I believe I have tried everything:
My application that is hosted on IIS is using a
'ApplicationPoolIdentity' as identity. I have tried changing the
identity to other, but to no avail. Only to be greeted by a similar
error, but with a changed user. (Havent tried using Custom account)
Tried sharing my localDB instance
with the following command sqllocaldb share mssqllocaldb IIS_DB.
Restarting the instance, changing my connection string data source
to the following (localdb)\\.\\IIS_DB.
Tried plainly using
SQLEXPRESS instance with the following data source .\\SQLEXPRESS.
I have added IIS APPPOOL\\DefaultAppPool user to all possible places, given full access to everything, allowed Everyone to access the folders where the database is located.
One thing I haven't tried is to try and repeat everything from scratch, since I might've messed something up. All help is appreciated.
IIS: version 10.0.19041.1
SSMS: version 18.12.1
Backend: .NET 6 minimal API + DAPPER
Thank you #Lex Li
I used to login to my PC via the microsoft acc and thus I never did use a windows acc. So whoever stumbles, keep in mind that it's easy to create the acc, windows helps you with that.
Other than that, what I was missing was exactly this. Use your own acc and not a DefaultAppPool (even though it should still work.).
Dont forget to check that your SQL instance is running:
Open cmd and write sqllocaldb i (this should show you all of your instances)
to check whether an instance is running. (It is started when you open your local SSMS and connect to your instance or you run it through cmd): Write sqllocaldb i instancename (should see it as running) - (if you want to restart it, write sqllocaldb stop instancename and then sqllocaldb start instancename.
Other than that, feel free to ask for help in the comments, I might remember this stuff even after a year or two. (Literally spent 7 days on this issue)

Error while using mongoose.I am not able to run my code and i have no idea how to get mongod services running

enter image description here
I am repeatedly getting this error while running my code.I googled it and it had something to do with mongod services not running but i dont know how to get the services started.
Your MongoDB database is most likely not running, from the path mentioned in your error, I am assuming you are running on Windows, I suggest you follow this guide: https://docs.mongodb.com/manual/tutorial/install-mongodb-on-windows/#create-database-directory
You are going to have to create the data directories then start the database through your terminal.

Trouble connecting Node to MongoDB on Windows

I'm having a difficult time figuring out how to run a node database. It has been several months since I set it up (following a tutorial) and I can't figure out how to connect to it again.
Here is what I have tried.
cd C:\Program Files\MongoDB\Server\3.4\bin
This is the folder which node is installed. Then I run the following:
mongod --dbpath d:\njs\nodetest1\data\
Which based on the following image, I would think should be correct, as the dbpath I list contains the following:
But then when I open a new instance of the command prompt, also navigate to cd C:\Program Files\MongoDB\Server\3.4\bin and enter
mongo
show databases
The results are, two databases titled DB_DROPPED & LOCAL both wit 0GB. I thought the database I'm looking for should be titled myCases, but that isn't showing up.
Does the picture I show suggest any cause? Am I simply skipping a step to connect? The database did not contain any sensitive information and I was just setting it up to test some stuff (and therefore had not been overly concerned with figuring out security), is it possible someone came in and "dropped" (i.e., deleted) the database?
Using mongod --dbpath d:\njs\nodetest1\data\.You are setting data directory to store all data.now just start mongoDB using this command "C:\Program Files\MongoDB\Server\3.4\bin\mongod.exe".

Azure storage emulator unable to initialize

I've upgraded Azure Storage Emulator from 2.3 to 2.4. WAStorageEmulator.exe has been renamed to AzureStorageEmulator.exe but that's not the issue.
When I run
AzureStorageEmulator init -forcecreate
I simply get an error that Google returns with zero results:
Error: User-specified instance not found. Please correct this and re-run initial
ization.
Edit
I had to do a start and stop and then I was able to init. Because I had previous version of emulator installed I already have WAStorageEmulatorDb34 on my local SQL server instance. After I run init command I can see that no new database is being created (like WAStorageEmulatorDb42).
So I thought that the newest version may be using older DB. I then ran a query in MSSMS to check for existing blob containers and I can still see both containers I created on the older emulator containing blobs I added.
When I then accessed Development Azure Storage in Visual Studio it showed no containers whatsoever. So the new version apparently doesn't use old DB. But which one? And where is it?
Ok so I thought I'd run init one more time but with additional parameters to put DB on my SQL server instance:
AzureStorageEmulator init -server localhost -sqlinstance MSSQLSERVER -forcecreate
And then I get the aforementioned error. Again...
I'm running CMD as admin with elevated permissions.
Solution that eventually worked
Additional info
Azure Storage Emulator normally creates tables in the LocalDB storage. Depending on the emulator version these may be in various DB instances. You can check each storage emulator version's configuration in
%USERPROFILE%\AppData\Local\[AzureStorageEmulatorFolder]\*.config
Different versions have different folder names from DevelopmentStorage, WAStorageEmulator to latest (4.2) AzureStorageEmulator.
In this subfolder you'll find at least one config file that will correspond to your installed Azure storage emulator's version. If you open it, you'll see how it's configured and where it saved its tables. This is also true if you create initialization on any existing full SQL server instance.
The problem when I was trying to initialize my Azure Storage Emulator (ASE) is that I was also providing SQL server's instance which is the default one (MSSQLSERVER). I shouldn't be providing this information in the first place but only provide information about server
So the correct command line call is
AzureStorageEmulator init -server localhost -forcecreate
This created my database on my local SQL server. From here on, it's up to you how you'll migrate from an existing ASE database (if you already had one before) to the new one.
The issue I ran into is more or less an user error.
Azure Storage Emulator 4.6
Error : User-specified instance not found. Please correct this and
re-run initialization.
and
Resolution : I didn't have a windows authenticated login to my local
sql instance.

MongoDB out of the box: not authorized for insert (Windows 7)

I've been following along with the actual MongoDB docs here
as well as several tutorial articles that are getting me absolutely nowhere.
Running a 64bit windows OS (which is a work computer, and my particular windows login is not an administrator login.. so I make sure to open any exe files as administrator). I can't do anything in the terminal beyond "mongo" or "use [db name]".
I cannot save or add anything like db.testData.insert( j ). Even typing "show dbs", I get an error that says
listDatabases failed:{ "ok" :0, "errmsg" : "unauthorized" } at src/mongo/shell/mongo.js:46
With every example I've followed, I can never seem to be "authenticated" to get past point A. Please help me! I have no idea what I'm doing wrong at this point.
UPDATE:
Sorry for the confusion, everyone. The problem turned out to be that I had an old MongoDB service still running in the background that I needed to disable.
The service must have been turned on while I was testing out some node packages or something. Once I disabled the service, everything started working as expected.
So for those of you who are having trouble, make sure you open up services.msc and make sure nothing is running MongoDB
As there isn't a formal installer for Windows, I'd recommend you delete the data folder and restart. Out of the box, there is no security in MongoDb, so you've followed a step which later requires a password. Either retrace your steps, or start over.
You don't need to switch to the admin Database. I'd suggest you instead switch to a test database for example:
> use test
switched to db test
By default, without extra configuration, on Windows you can delete the contents of c:\data\db when MongoDb isn't running (but if you're using a configuration file that specifies the dbpath, delete the contents of that folder).
There are a number of tutorials with details of how to configure users/security with Mongodb that you may want to read after you've resolved this issue.
There's little reason to create users and administrative control with MongoDB until you gain some experience with the platform. In fact, I wouldn't recommend it at all. It just gets in the way as you're seeing for no real gain.

Resources