NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

#DB Migration

I learned how to download and setup MongoDB on my ubuntu system, for that I have to go to MongoDB documentation (https://www.mongodb.com/docs/manual/tutorial/install-mongodb-on-ubuntu), and follow th e process.

I have to isntall gnuppg and curl if they are not installed by using [sudo apt-get install gnupg curl], then import the mongodbpublic gpg key using [curl -fsSL https://www.mongodb.org/static/pgp/server-7.0.asc | sudo gpg -o /usr/share/keyrings/mongodb-server-7.0.gpg --dearmor], then create a list file for my version of ubuntu using [echo "deb [ arch=amd64,arm64 signed-by=/usr/share/keyrings/mongodb-server-7.0.gpg ] https://repo.mongodb.org/apt/ubuntu jammy/mongodb-org/7.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-7.0.list], then run [sudo apt-get update], then run [sudo apt-get install -y mongodb-org], then start mongod service using [sudo systemctl start mongod], then I can check status by using [sudo systemctl status mongod], then I can connect to mongod using command [mongosh].

Then I can us command [use admin ] to switch to the admin user in mongodb and use [db.createUser({user:"admin", pwd:"password", roles:[{role:"root", db:"admin"}]})] to create credentials for user -> admin, and I can now exit mongosh and restart the mongod service by using [sudo systemctl restart mongod]

and then I can login to mongosh using this credetial by using the command [mongosh -u admin -p admin123 --authenticationDatabase admin]

I went to the link [https://www.mongodb.com/try/download/compass] and downloaded the mongodb compass pacakage and intalled it though apt package manager, This is a GUI to interact with mongodb and I can perform everthing though the GUI also.

I created on database and switched into it using the command [use smapledb] and then I ran this command [for (var i = 1; i <= 100000; i++) {
db.users.insertOne({
name: "User" + i,
age: Math.floor(Math.random() * 50) + 18,
email: "user" + i + "@example.com",
country: ["USA", "Canada", "UK", "Germany", "France"][Math.floor(Math.random() * 5)]
});
}]
It inserted 1 lakhs data into my database in users table.

I used command [mongoexport --db=sampledb --collection=users --type=csv --fields=_id,name,age,email,country,address --out=/home/princekumar/sample.csv], to export my data to csv file, here --db is for databasename, --collection is for tables and --fileds is for fields I want to export.

     
 
what is notes.io
 

Notes is a web-based application for online taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000+ notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 14 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.