{"id":1889,"date":"2022-06-29T11:49:53","date_gmt":"2022-06-29T11:49:53","guid":{"rendered":"https:\/\/www.checkmateq.com\/blog\/?p=1889"},"modified":"2023-08-06T15:13:46","modified_gmt":"2023-08-06T15:13:46","slug":"mysql-tables-to-mongodb","status":"publish","type":"post","link":"https:\/\/www.checkmateq.com\/blog\/mysql-tables-to-mongodb","title":{"rendered":"How to Export MySQL Tables to MongoDB?"},"content":{"rendered":"<p><a href=\"https:\/\/www.checkmateq.com\/full-stack-development\"><strong>MySQL<\/strong><\/a> is one of the most used relational database managements (RDMS) based on SQL, it stores data in rows and columns each row will have unique data for the defined columns, and every RDMS follows a predefined schema to store data, use a relational database management system when you want your data to be stored in a particular predefined schema.<\/p>\n<h3>When to use MongoDB?<\/h3>\n<p><a href=\"https:\/\/www.checkmateq.com\/python-development\">MongoDB<\/a> is a non-relational document database used to store unstructured data, it has flexible data model as it allows you to store data in Json format, it uses collections and documents unlike tables and rows in relational database, documents consist of key-value pairs which are mongo dB&#8217;s basic unit of data, fields in a MongoDB document can be indexed with primary and secondary index&#8217;s.<\/p>\n<p>while MongoDB is more flexible and ensures data availability ,MySQL ensures greater reliability of transactions ,so if you have a application where there is a need to perform complex queries and you do not intend to add more features\u00a0 it&#8217;s better to stay on MySQL, on the other side ,if you are constantly adding new features and functionalities to your application it&#8217;s better to migrate to MongoDB.<\/p>\n<p>In this blog we will see a very simple way of migration where you export tables from mysql-workbench and mysql command line to csv files, and importing a csv file to mongodb.<\/p>\n<p><strong>MySQL to MongoDB terminology mapping chart<\/strong><\/p>\n<p><img loading=\"lazy\" class=\" wp-image-1914 aligncenter\" src=\"https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/06\/migration-1-300x196.jpeg\" alt=\"\" width=\"586\" height=\"383\" srcset=\"https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/06\/migration-1-300x196.jpeg 300w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/06\/migration-1.jpeg 715w\" sizes=\"(max-width: 586px) 85vw, 586px\" \/><\/p>\n<h3><strong>Exporting tables using MySQL workbench to\u00a0 a CSV file<\/strong><\/h3>\n<p>On your MySQL workbench click on &#8220;Schemas&#8221; under navigator.<\/p>\n<p><img loading=\"lazy\" class=\" wp-image-1942 aligncenter\" src=\"https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/06\/Screenshot-576-300x169.png\" alt=\"\" width=\"637\" height=\"359\" srcset=\"https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/06\/Screenshot-576-300x169.png 300w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/06\/Screenshot-576-1024x576.png 1024w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/06\/Screenshot-576-768x432.png 768w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/06\/Screenshot-576-1536x864.png 1536w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/06\/Screenshot-576-1200x675.png 1200w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/06\/Screenshot-576.png 1920w\" sizes=\"(max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 984px) 61vw, (max-width: 1362px) 45vw, 600px\" \/><\/p>\n<p>Select the database from which you want to export table and right click on the table name then click on &#8220;Table Data Export Wizard&#8221; as shown in below snap shot, I am exporting table people from database &#8220;abc&#8221; .<\/p>\n<p><img loading=\"lazy\" class=\" wp-image-1892 aligncenter\" src=\"https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/06\/Screenshot-543-300x169.png\" alt=\"\" width=\"719\" height=\"405\" srcset=\"https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/06\/Screenshot-543-300x169.png 300w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/06\/Screenshot-543-1024x576.png 1024w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/06\/Screenshot-543-768x432.png 768w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/06\/Screenshot-543-1536x864.png 1536w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/06\/Screenshot-543-1200x675.png 1200w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/06\/Screenshot-543.png 1920w\" sizes=\"(max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 984px) 61vw, (max-width: 1362px) 45vw, 600px\" \/><\/p>\n<p>data of table &#8220;people&#8221; from abc database.<\/p>\n<p><img loading=\"lazy\" class=\"wp-image-1946 aligncenter\" src=\"https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/06\/Screenshot-583-300x169.png\" alt=\"\" width=\"714\" height=\"402\" srcset=\"https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/06\/Screenshot-583-300x169.png 300w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/06\/Screenshot-583-1024x576.png 1024w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/06\/Screenshot-583-768x432.png 768w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/06\/Screenshot-583-1536x864.png 1536w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/06\/Screenshot-583-1200x675.png 1200w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/06\/Screenshot-583.png 1920w\" sizes=\"(max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 984px) 61vw, (max-width: 1362px) 45vw, 600px\" \/><\/p>\n<p>Now select the columns that you want to export and click on next.<\/p>\n<p><img loading=\"lazy\" class=\" wp-image-1893 aligncenter\" src=\"https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/06\/Screenshot-544-300x169.png\" alt=\"\" width=\"686\" height=\"386\" srcset=\"https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/06\/Screenshot-544-300x169.png 300w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/06\/Screenshot-544-1024x576.png 1024w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/06\/Screenshot-544-768x432.png 768w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/06\/Screenshot-544-1536x864.png 1536w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/06\/Screenshot-544-1200x675.png 1200w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/06\/Screenshot-544.png 1920w\" sizes=\"(max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 984px) 61vw, (max-width: 1362px) 45vw, 600px\" \/><\/p>\n<p>give file path where you want to store data and select the file type then click on &#8220;Next&gt;&#8221;, as you can see ,\u00a0 I am saving my file in downloads.<\/p>\n<p><img loading=\"lazy\" class=\" wp-image-1895 aligncenter\" src=\"https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/06\/Screenshot-545-300x169.png\" alt=\"\" width=\"700\" height=\"394\" srcset=\"https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/06\/Screenshot-545-300x169.png 300w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/06\/Screenshot-545-1024x576.png 1024w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/06\/Screenshot-545-768x432.png 768w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/06\/Screenshot-545-1536x864.png 1536w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/06\/Screenshot-545-1200x675.png 1200w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/06\/Screenshot-545.png 1920w\" sizes=\"(max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 984px) 61vw, (max-width: 1362px) 45vw, 600px\" \/><\/p>\n<p>click on Next on &#8220;Export Data&#8221; tab and click on &#8216;Finish&#8217; on Export Results tab.<\/p>\n<p><img loading=\"lazy\" class=\" wp-image-1899 aligncenter\" src=\"https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/06\/Screenshot-547-1-300x169.png\" alt=\"\" width=\"688\" height=\"388\" srcset=\"https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/06\/Screenshot-547-1-300x169.png 300w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/06\/Screenshot-547-1-1024x576.png 1024w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/06\/Screenshot-547-1-768x432.png 768w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/06\/Screenshot-547-1-1536x864.png 1536w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/06\/Screenshot-547-1-1200x675.png 1200w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/06\/Screenshot-547-1.png 1920w\" sizes=\"(max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 984px) 61vw, (max-width: 1362px) 45vw, 600px\" \/><\/p>\n<p>Now go check your csv file in file path you gave, below is the snapshot of the file generated.<\/p>\n<p><img loading=\"lazy\" class=\" wp-image-1948 aligncenter\" src=\"https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/06\/Screenshot-588-300x169.png\" alt=\"\" width=\"626\" height=\"353\" srcset=\"https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/06\/Screenshot-588-300x169.png 300w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/06\/Screenshot-588-1024x576.png 1024w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/06\/Screenshot-588-768x432.png 768w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/06\/Screenshot-588-1536x864.png 1536w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/06\/Screenshot-588-1200x675.png 1200w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/06\/Screenshot-588.png 1920w\" sizes=\"(max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 984px) 61vw, (max-width: 1362px) 45vw, 600px\" \/><\/p>\n<h3>Exporting table from MySQL Command line (Server)<\/h3>\n<p>Below is the snapshot of a table data &#8220;Customers&#8221; from a database named <strong>dbone<\/strong><\/p>\n<p><img loading=\"lazy\" class=\" wp-image-1949 aligncenter\" src=\"https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/06\/Screenshot-591-300x168.jpeg\" alt=\"\" width=\"696\" height=\"390\" srcset=\"https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/06\/Screenshot-591-300x168.jpeg 300w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/06\/Screenshot-591-1024x575.jpeg 1024w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/06\/Screenshot-591-768x431.jpeg 768w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/06\/Screenshot-591-1200x673.jpeg 1200w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/06\/Screenshot-591.jpeg 1251w\" sizes=\"(max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 984px) 61vw, (max-width: 1362px) 45vw, 600px\" \/><\/p>\n<p>To export your table from command line you need to add below line\u00a0 to mysql-server\u00a0 configuration file under [mysqld] and save it.<\/p>\n<pre>secure-file-priv = \"\"<\/pre>\n<p>This will enable users to export or import data from database server, restart your mysql server after saving the file.<\/p>\n<p><img loading=\"lazy\" class=\" wp-image-1952 aligncenter\" src=\"https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/06\/Screenshot-592-300x169.png\" alt=\"\" width=\"681\" height=\"384\" srcset=\"https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/06\/Screenshot-592-300x169.png 300w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/06\/Screenshot-592-1024x576.png 1024w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/06\/Screenshot-592-768x432.png 768w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/06\/Screenshot-592-1536x864.png 1536w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/06\/Screenshot-592-1200x675.png 1200w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/06\/Screenshot-592.png 1920w\" sizes=\"(max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 984px) 61vw, (max-width: 1362px) 45vw, 600px\" \/><\/p>\n<h3><strong>Command to export\u00a0 a table to a csv file<\/strong><\/h3>\n<p>Login to your mysql shell and use below command to export your table.<\/p>\n<pre>TABLE <strong>Customers<\/strong> INTO OUTFILE <strong>'Customers.txt<\/strong>' FIELDS TERMINATED BY ';' LINES TERMINATED BY '\\n';<\/pre>\n<p><img loading=\"lazy\" class=\" wp-image-1954 aligncenter\" src=\"https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/06\/Screenshot-594-300x27.jpeg\" alt=\"\" width=\"700\" height=\"63\" srcset=\"https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/06\/Screenshot-594-300x27.jpeg 300w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/06\/Screenshot-594-1024x93.jpeg 1024w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/06\/Screenshot-594-768x70.jpeg 768w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/06\/Screenshot-594-1536x139.jpeg 1536w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/06\/Screenshot-594-1200x109.jpeg 1200w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/06\/Screenshot-594.jpeg 1877w\" sizes=\"(max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 984px) 61vw, (max-width: 1362px) 45vw, 600px\" \/><\/p>\n<p>here <strong>Customers<\/strong> is the table name that I want to export and <strong>Customers.txt<\/strong> if the file name to which I am exporting the table file will be created at \u00a0\/var\/lib\/mysql\/database_name (may vary based on OS), you can also give a specific path instead of file name , below is snapshot of\u00a0 \u00a0CSV file(exported table data) column names are not exported here.<\/p>\n<p><img loading=\"lazy\" class=\" wp-image-1955 aligncenter\" src=\"https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/06\/Screenshot-595-300x61.jpeg\" alt=\"\" width=\"703\" height=\"143\" srcset=\"https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/06\/Screenshot-595-300x61.jpeg 300w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/06\/Screenshot-595-1024x210.jpeg 1024w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/06\/Screenshot-595-768x157.jpeg 768w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/06\/Screenshot-595-1200x246.jpeg 1200w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/06\/Screenshot-595.jpeg 1397w\" sizes=\"(max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 984px) 61vw, (max-width: 1362px) 45vw, 600px\" \/><\/p>\n<h3>Importing a CSV file to MongoDB database using mongoimport\u00a0 command<\/h3>\n<p>you can use mongoimport command to import CSV files it&#8217;s fast and multi threaded<\/p>\n<p><strong>Example-1: Importing a CSV file which does not has field names<\/strong><\/p>\n<p>Now lets see how to use mongoimport command to import a CSV file which does not have header (column\/field names), below is the snapshot of data in a csv file named Customers.<\/p>\n<p><img loading=\"lazy\" class=\" wp-image-1959 aligncenter\" src=\"https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/06\/Screenshot-596-300x40.jpeg\" alt=\"\" width=\"691\" height=\"92\" srcset=\"https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/06\/Screenshot-596-300x40.jpeg 300w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/06\/Screenshot-596-1024x135.jpeg 1024w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/06\/Screenshot-596-768x102.jpeg 768w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/06\/Screenshot-596-1536x203.jpeg 1536w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/06\/Screenshot-596-1200x159.jpeg 1200w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/06\/Screenshot-596.jpeg 1626w\" sizes=\"(max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 984px) 61vw, (max-width: 1362px) 45vw, 600px\" \/><\/p>\n<p>As you can see in the below image database &#8220;databaseOne&#8221; only has one table.<\/p>\n<p><img loading=\"lazy\" class=\" wp-image-1972 aligncenter\" src=\"https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/06\/Screenshot-597-300x50.jpeg\" alt=\"\" width=\"702\" height=\"117\" srcset=\"https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/06\/Screenshot-597-300x50.jpeg 300w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/06\/Screenshot-597-1024x170.jpeg 1024w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/06\/Screenshot-597-768x128.jpeg 768w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/06\/Screenshot-597-1536x256.jpeg 1536w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/06\/Screenshot-597-1200x200.jpeg 1200w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/06\/Screenshot-597.jpeg 1719w\" sizes=\"(max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 984px) 61vw, (max-width: 1362px) 45vw, 600px\" \/><\/p>\n<p>execute below command on your terminal to import data from a csv file (not on mongo shell).<\/p>\n<pre>mongoimport --db <strong>databaseOne<\/strong> --collection=<strong>Customers<\/strong> --file=<strong>Customers.csv<\/strong> --type=csv --fields=\"ID\",\"Name\",\"Occupation\",\"Age\"<\/pre>\n<p>Here <strong>databaseOne<\/strong> is database that I am importing data to ,<strong>Customers\u00a0<\/strong>is the new collection created to store imported data,<strong> Customests.csv<\/strong> is the CSV file name that the data is imported from and use option <strong>fields<\/strong> to give field names.<\/p>\n<p><img loading=\"lazy\" class=\" wp-image-1985 aligncenter\" src=\"https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/06\/Screenshot-599-300x66.jpeg\" alt=\"\" width=\"750\" height=\"165\" srcset=\"https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/06\/Screenshot-599-300x66.jpeg 300w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/06\/Screenshot-599-1024x224.jpeg 1024w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/06\/Screenshot-599-768x168.jpeg 768w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/06\/Screenshot-599-1200x263.jpeg 1200w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/06\/Screenshot-599.jpeg 1434w\" sizes=\"(max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 984px) 61vw, (max-width: 1362px) 45vw, 600px\" \/><\/p>\n<p><strong>Example-2: Importing a CSV file which has field names<\/strong><\/p>\n<p>Observe the below given snapshot of\u00a0 <strong>abc.csv<\/strong> file it has field names, use option<strong> headerline\u00a0<\/strong>along with mongoimport command, option headerline notifies mongoimport that not to import first line as document as it contains field names.<\/p>\n<p><img loading=\"lazy\" class=\" wp-image-1987 aligncenter\" src=\"https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/06\/Screenshot-600-300x60.jpeg\" alt=\"\" width=\"655\" height=\"131\" srcset=\"https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/06\/Screenshot-600-300x60.jpeg 300w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/06\/Screenshot-600-1024x206.jpeg 1024w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/06\/Screenshot-600-768x154.jpeg 768w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/06\/Screenshot-600-1200x241.jpeg 1200w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/06\/Screenshot-600.jpeg 1435w\" sizes=\"(max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 984px) 61vw, (max-width: 1362px) 45vw, 600px\" \/><\/p>\n<p><strong>Command to import data into mongodb from csv file with header\u00a0<\/strong><\/p>\n<pre>mongoimport --db <strong>databaseOne<\/strong> --collection=<strong>Persons<\/strong> --file=<strong>abc.csv<\/strong> --type=csv --headerline<\/pre>\n<p><strong>databaseOne<\/strong> is database that I am importing data to ,<strong>Persons\u00a0<\/strong>is the new collection created to store imported data,<strong> abc.csv <\/strong>is the CSV file name that the data is imported from.<\/p>\n<p><img loading=\"lazy\" class=\" wp-image-1993 aligncenter\" src=\"https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/06\/Screenshot-602-300x24.jpeg\" alt=\"\" width=\"1788\" height=\"143\" srcset=\"https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/06\/Screenshot-602-300x24.jpeg 300w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/06\/Screenshot-602-1024x81.jpeg 1024w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/06\/Screenshot-602-768x61.jpeg 768w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/06\/Screenshot-602-1536x122.jpeg 1536w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/06\/Screenshot-602-1200x95.jpeg 1200w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/06\/Screenshot-602.jpeg 1768w\" sizes=\"(max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 1362px) 62vw, 840px\" \/><\/p>\n<p>Snapshot of collection created from imported file<\/p>\n<p><img loading=\"lazy\" class=\" wp-image-2007 aligncenter\" src=\"https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/06\/Screenshot-603-1-300x62.jpeg\" alt=\"\" width=\"653\" height=\"135\" srcset=\"https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/06\/Screenshot-603-1-300x62.jpeg 300w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/06\/Screenshot-603-1-1024x211.jpeg 1024w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/06\/Screenshot-603-1-768x158.jpeg 768w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/06\/Screenshot-603-1-1536x317.jpeg 1536w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/06\/Screenshot-603-1-1200x247.jpeg 1200w, https:\/\/www.checkmateq.com\/blog\/wp-content\/uploads\/2022\/06\/Screenshot-603-1.jpeg 1552w\" sizes=\"(max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 984px) 61vw, (max-width: 1362px) 45vw, 600px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p>Please <a href=\"https:\/\/www.checkmateq.com\/contact-us\">contact<\/a> with our technical consultants if you want to develop any <a href=\"https:\/\/www.checkmateq.com\/google-cloud\">cloud migration<\/a> strategy. Our cloud engineers can provide you appropriate infrastructure migration plan. You can hire Checkmate Global Technologies cloud engineer today.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>MySQL is one of the most used relational database managements (RDMS) based on SQL, it stores data in rows and columns each row will have unique data for the defined columns, and every RDMS follows a predefined schema to store data, use a relational database management system when you want your data to be stored &hellip; <a href=\"https:\/\/www.checkmateq.com\/blog\/mysql-tables-to-mongodb\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;How to Export MySQL Tables to MongoDB?&#8221;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":2067,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[3,2,11,63,23,16,24,8],"_links":{"self":[{"href":"https:\/\/www.checkmateq.com\/blog\/wp-json\/wp\/v2\/posts\/1889"}],"collection":[{"href":"https:\/\/www.checkmateq.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.checkmateq.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.checkmateq.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.checkmateq.com\/blog\/wp-json\/wp\/v2\/comments?post=1889"}],"version-history":[{"count":27,"href":"https:\/\/www.checkmateq.com\/blog\/wp-json\/wp\/v2\/posts\/1889\/revisions"}],"predecessor-version":[{"id":4286,"href":"https:\/\/www.checkmateq.com\/blog\/wp-json\/wp\/v2\/posts\/1889\/revisions\/4286"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.checkmateq.com\/blog\/wp-json\/wp\/v2\/media\/2067"}],"wp:attachment":[{"href":"https:\/\/www.checkmateq.com\/blog\/wp-json\/wp\/v2\/media?parent=1889"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.checkmateq.com\/blog\/wp-json\/wp\/v2\/categories?post=1889"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.checkmateq.com\/blog\/wp-json\/wp\/v2\/tags?post=1889"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}