

{"id":105009,"date":"2021-12-21T09:00:12","date_gmt":"2021-12-21T03:30:12","guid":{"rendered":"https:\/\/data-flair.training\/blogs\/?p=105009"},"modified":"2021-12-21T11:03:02","modified_gmt":"2021-12-21T05:33:02","slug":"nodejs-mysql-tutorial","status":"publish","type":"post","link":"https:\/\/data-flair.training\/blogs\/nodejs-mysql-tutorial\/","title":{"rendered":"Node.js MySQL Tutorial"},"content":{"rendered":"<p>In this article, we will see how we can use the sql database with node.js. We will look at how to create a database, connect databases, create a table and other sql methods with code and examples.<\/p>\n<h3>What is MySQL?<\/h3>\n<p>Mysql is a relational database management system. It is an open source and most popular relational database written in C and C++.<\/p>\n<h3>Why connect MySQL with nodejs?<\/h3>\n<ul>\n<li>MySQL is a free database.<\/li>\n<li>It supports most of the operating system.<\/li>\n<li>It can be used with almost all the languages.<\/li>\n<li>Fast even when it has large data.<\/li>\n<\/ul>\n<h3>How to Install MySQL:<\/h3>\n<p>Npm has a mysql module which we will use in this article. To install it run the below command.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">Npm install mysql<\/pre>\n<p>To utilize it use the require function:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">Let mysql=require(\u2018mysql\u2019)<\/pre>\n<h3>Connect to MySQL:<\/h3>\n<p>Replace the username and password in the below code with your mysql credentials.<\/p>\n<p><strong>Code for creating connection:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">let mysql = require('mysql');\r\nlet con = mysql.createConnection({\r\n    host: \"localhost\",\r\n    user: \"yourusername\",\r\n    password: \"yourpassword\"\r\n});\r\ncon.connect(function (err) {\r\n    if (err) throw err;\r\n    console.log(\"Connected!\");\r\n});\r\n<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">Connected<\/div>\n<h3>Query for Creating a database:<\/h3>\n<p>Use CREATE DATABASE to create a database in MySQL.<\/p>\n<p><strong>Code for creating a database:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">var mysql = require('mysql');\r\nvar con = mysql.createConnection({\r\n    host: \"localhost\",\r\n    user: \"root\",\r\n});\r\ncon.connect(function (err) {\r\n    if (err) throw err;\r\n    console.log(\"Connected!\");\r\n    con.query(\"CREATE DATABASE dataflair\", function (err, result) {\r\n        if (err) throw err;\r\n        console.log(\"Database created\");\r\n    });\r\n});\r\n<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/12\/nodejs-sql-create-database.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-105034\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/12\/nodejs-sql-create-database.webp\" alt=\"nodejs sql create database\" width=\"1366\" height=\"723\" \/><\/a><\/p>\n<h3>Creating Table in MySQL:<\/h3>\n<p>Use CREATE TABLE to create a table in MySQL database.<\/p>\n<p><strong>Code for creating a table:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">var mysql = require('mysql');\r\nvar con = mysql.createConnection({\r\n    host: \"localhost\",\r\n    user: \"root\",\r\n    database: \"dataflair\"\r\n});\r\ncon.connect(function (err) {\r\n    if (err) throw err;\r\n    console.log(\"Connected!\");\r\n    var sql = \"CREATE TABLE student (id INT, name VARCHAR(255), age INT(3), city VARCHAR(255))\";\r\n    con.query(sql, function (err, result) {\r\n        if (err) throw err;\r\n        console.log(\"Table created\");\r\n    });\r\n})\r\n<\/pre>\n<p><strong>Output<\/strong><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/12\/nodejs-sql-create-table.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-105035\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/12\/nodejs-sql-create-table.webp\" alt=\"nodejs sql create table\" width=\"1366\" height=\"723\" \/><\/a><\/p>\n<h3>Insert into Table:<\/h3>\n<p>Use INSERT INTO to insert a row in the MySQL database table.<\/p>\n<p><strong>Code for inserting into table:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">var mysql = require('mysql');\r\nvar con = mysql.createConnection({\r\n    host: \"localhost\",\r\n    user: \"root\",\r\n    database: \"dataflair\"\r\n});\r\ncon.connect(function (err) {\r\n    if (err) throw err;\r\n    console.log(\"Connected!\");\r\n    var sql = \"INSERT INTO student (id, name, age, city) VALUES ('1', 'Abc', '27', 'delhi')\";\r\n    con.query(sql, function (err, result) {\r\n        if (err) throw err;\r\n        console.log(\"1 record inserted\");\r\n    });\r\n});\r\n<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/12\/nodejs-sql-insert.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-105036\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/12\/nodejs-sql-insert.webp\" alt=\"nodejs sql insert\" width=\"1366\" height=\"723\" \/><\/a><\/p>\n<h3>Update records:<\/h3>\n<p>Use UPDATE to update a row in the MySQL database table.<\/p>\n<p><strong>Code for updating a record:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">var mysql = require('mysql');\r\nvar con = mysql.createConnection({\r\n    host: \"localhost\",\r\n    user: \"root\",\r\n    database: \"dataflair\"\r\n});\r\ncon.connect(function (err) {\r\n    if (err) throw err;\r\n    var sql = \"UPDATE student SET city = 'mumbai' WHERE city = 'delhi'\";\r\n    con.query(sql, function (err, result) {\r\n        if (err) throw err;\r\n        console.log(result.affectedRows + \" record(s) updated\");\r\n    });\r\n});\r\n<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/12\/nodejs-sql-update.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-105037\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/12\/nodejs-sql-update.webp\" alt=\"nodejs sql update\" width=\"1366\" height=\"723\" \/><\/a><\/p>\n<h3>Delete records:<\/h3>\n<p>Use DELETE FROM to delete a row in the MySQL database table.<\/p>\n<p><strong>Code for deleting a record:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">var mysql = require('mysql');\r\nvar con = mysql.createConnection({\r\n    host: \"localhost\",\r\n    user: \"root\",\r\n    database: \"dataflair\"\r\n});\r\ncon.connect(function (err) {\r\n    if (err) throw err;\r\n    var sql = \"DELETE FROM student WHERE city = 'mumbai'\";\r\n    con.query(sql, function (err, result) {\r\n        if (err) throw err;\r\n        console.log(\"Number of records deleted: \" + result.affectedRows);\r\n    });\r\n});\r\n<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/12\/nodejs-sql-delete.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-105038\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/12\/nodejs-sql-delete.webp\" alt=\"nodejs sql delete\" width=\"1366\" height=\"723\" \/><\/a><\/p>\n<h3>SELECT records:<\/h3>\n<p>Use SELECT to see a row in the MySQL database table.<\/p>\n<p><strong>Code for using select statement :<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">var mysql = require('mysql');\r\nvar con = mysql.createConnection({\r\n    host: \"localhost\",\r\n    user: \"root\",\r\n    database: \"dataflair\"\r\n});\r\ncon.connect(function (err) {\r\n    if (err) throw err;\r\n    con.query(\"SELECT * FROM student\", function (err, result) {\r\n        if (err) throw err;\r\n        console.log(result);\r\n    });\r\n});\r\n<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/12\/nodejs-sql-select.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-105039\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/12\/nodejs-sql-select.webp\" alt=\"nodejs sql select\" width=\"1366\" height=\"723\" \/><\/a><\/p>\n<h3>Mysql Where:<\/h3>\n<p>If we want to select a specific row based on some criteria we use where.<\/p>\n<p><strong>Code for mysql where:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">var mysql = require('mysql');\r\nvar con = mysql.createConnection({\r\n    host: \"localhost\",\r\n    user: \"root\",\r\n    database: \"dataflair\"\r\n});\r\n \r\n \r\ncon.connect(function (err) {\r\n    if (err) throw err;\r\n    con.query(\"SELECT * FROM student WHERE city = 'delhi'\", function (err, result) {\r\n        if (err) throw err;\r\n        console.log(result);\r\n    });\r\n});\r\n<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">{id:1,name:\u2019ABC\u2019,age:27,city:\u2019delhi\u2019}<\/div>\n<h3>Mysql order by:<\/h3>\n<p>You can use order by to sort the data.<\/p>\n<p><strong>Code for Mysql order by<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">var mysql = require('mysql');\r\nvar con = mysql.createConnection({\r\n    host: \"localhost\",\r\n    user: \"root\",\r\n    database: \"dataflair\"\r\n});\r\ncon.connect(function (err) {\r\n    if (err) throw err;\r\n    con.query(\"SELECT * FROM student ORDER BY name\", function (err, result) {\r\n        if (err) throw err;\r\n        console.log(result);\r\n    });\r\n})\r\n<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">{id:1,name:\u2019ABC\u2019,age:27,city:\u2019delhi\u2019}<br \/>\n{id:2,name:\u2019XYZ\u2019,age:28,city:\u2019delhi\u2019}<\/div>\n<h3>Mysql LIMIT:<\/h3>\n<p>In order to get only a few rows from the table we use a limit.<\/p>\n<p><strong>Code for mysql limit:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">var mysql = require('mysql');\r\nvar con = mysql.createConnection({\r\n    host: \"localhost\",\r\n    user: \"root\",\r\n    database: \"dataflair\"\r\n});\r\n \r\ncon.connect(function (err) {\r\n    if (err) throw err;\r\n    var sql = \"SELECT * FROM student LIMIT 1\";\r\n    con.query(sql, function (err, result) {\r\n        if (err) throw err;\r\n        console.log(result);\r\n    });\r\n});\r\n<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">{id:1,name:\u2019ABC\u2019,age:27,city:\u2019delhi\u2019}<\/div>\n<h3>Mysql JOIN:<\/h3>\n<p>In order to join two tables we use the mysql JOIN<\/p>\n<p><strong>Code for mysql join:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">var mysql = require('mysql');\r\nvar con = mysql.createConnection({\r\n    host: \"localhost\",\r\n    user: \"root\",\r\n    database: \"dataflair\"\r\n});\r\ncon.connect(function (err) {\r\n    if (err) throw err;\r\n    var sql = \"SELECT student.name AS name, school.name AS school FROM student JOIN school ON student.school = school.id\";\r\n    con.query(sql, function (err, result) {\r\n        if (err) throw err;\r\n        console.log(result);\r\n    });\r\n});\r\n<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">{name:\u2019ABC\u2019,school:\u2019school1\u2019}<br \/>\n{name:\u2019XYZ\u2019,school:\u2019school2\u2019}<\/div>\n<h3>DROP Table:<\/h3>\n<p>Use DROP TABLE to drop a MySQL database table.<\/p>\n<p><strong>Code for dropping table:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">var mysql = require('mysql');\r\nvar con = mysql.createConnection({\r\n    host: \"localhost\",\r\n    user: \"root\",\r\n    database: \"dataflair\"\r\n});\r\ncon.connect(function (err) {\r\n    if (err) throw err;\r\n    var sql = \"DROP TABLE student\";\r\n    con.query(sql, function (err, result) {\r\n        if (err) throw err;\r\n        console.log(\"Table deleted\");\r\n    });\r\n});\r\n<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/12\/nodejs-drop-table.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-105040\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/12\/nodejs-drop-table.webp\" alt=\"nodejs drop table\" width=\"1366\" height=\"723\" \/><\/a><\/p>\n<h3>Calling MySql stored procedure:<\/h3>\n<p>You can call stored procedures and use it for query;<\/p>\n<p><strong>Code for stored procedure:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">DELIMITER $$\r\nCREATE PROCEDURE `selectAll`()\r\nBEGIN\r\n    SELECT * FROM student;\r\nEND$$\r\nDELIMITER ;\r\n \r\nfunction call(sp) {\r\n    let spQuery = 'CALL ??';\r\n    let query = mysql.format(spQuery,[spName]);\r\n    pool.query(query,(err, result) =&gt; {\r\n        if(err) {\r\n            console.error(err);\r\n            return;\r\n        }\r\n    });\r\n}\r\n<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<div class=\"code-output\">{id:1,name:\u2019ABC\u2019,age:27,city:\u2019delhi\u2019}<br \/>\n{id:2,name:\u2019XYZ\u2019,age:28,city:\u2019delhi\u2019}<\/div>\n<h3>Conclusion:<\/h3>\n<p>We hope you were able to learn using Mysql with node js. Do check the DataFlair website for other amazing articles.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this article, we will see how we can use the sql database with node.js. We will look at how to create a database, connect databases, create a table and other sql methods with&#46;&#46;&#46;<\/p>\n","protected":false},"author":5,"featured_media":105050,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[25259],"tags":[25992],"class_list":["post-105009","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-node-js-tutorials","tag-node-js-mysql"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.8 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Node.js MySQL Tutorial - DataFlair<\/title>\n<meta name=\"description\" content=\"Learn about Node.js MySQL. Learn to install and connect MySQL to Nodejs, create database &amp; table, insert in table, update &amp; delete records etc\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/data-flair.training\/blogs\/nodejs-mysql-tutorial\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Node.js MySQL Tutorial - DataFlair\" \/>\n<meta property=\"og:description\" content=\"Learn about Node.js MySQL. Learn to install and connect MySQL to Nodejs, create database &amp; table, insert in table, update &amp; delete records etc\" \/>\n<meta property=\"og:url\" content=\"https:\/\/data-flair.training\/blogs\/nodejs-mysql-tutorial\/\" \/>\n<meta property=\"og:site_name\" content=\"DataFlair\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/DataFlairWS\/\" \/>\n<meta property=\"article:published_time\" content=\"2021-12-21T03:30:12+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-12-21T05:33:02+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/12\/nodejs-mysql.webp\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"628\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/webp\" \/>\n<meta name=\"author\" content=\"DataFlair Team\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@DataFlairWS\" \/>\n<meta name=\"twitter:site\" content=\"@DataFlairWS\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"DataFlair Team\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 minutes\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Node.js MySQL Tutorial - DataFlair","description":"Learn about Node.js MySQL. Learn to install and connect MySQL to Nodejs, create database & table, insert in table, update & delete records etc","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/data-flair.training\/blogs\/nodejs-mysql-tutorial\/","og_locale":"en_US","og_type":"article","og_title":"Node.js MySQL Tutorial - DataFlair","og_description":"Learn about Node.js MySQL. Learn to install and connect MySQL to Nodejs, create database & table, insert in table, update & delete records etc","og_url":"https:\/\/data-flair.training\/blogs\/nodejs-mysql-tutorial\/","og_site_name":"DataFlair","article_publisher":"https:\/\/www.facebook.com\/DataFlairWS\/","article_published_time":"2021-12-21T03:30:12+00:00","article_modified_time":"2021-12-21T05:33:02+00:00","og_image":[{"width":1200,"height":628,"url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/12\/nodejs-mysql.webp","type":"image\/webp"}],"author":"DataFlair Team","twitter_card":"summary_large_image","twitter_creator":"@DataFlairWS","twitter_site":"@DataFlairWS","twitter_misc":{"Written by":"DataFlair Team","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/data-flair.training\/blogs\/nodejs-mysql-tutorial\/#article","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/nodejs-mysql-tutorial\/"},"author":{"name":"DataFlair Team","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/person\/7f83c342f5d1632d6f7b4b0b0f447823"},"headline":"Node.js MySQL Tutorial","datePublished":"2021-12-21T03:30:12+00:00","dateModified":"2021-12-21T05:33:02+00:00","mainEntityOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/nodejs-mysql-tutorial\/"},"wordCount":452,"commentCount":0,"publisher":{"@id":"https:\/\/data-flair.training\/blogs\/#organization"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/nodejs-mysql-tutorial\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/12\/nodejs-mysql.webp","keywords":["Node.js MySQL"],"articleSection":["Node Js Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/data-flair.training\/blogs\/nodejs-mysql-tutorial\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/data-flair.training\/blogs\/nodejs-mysql-tutorial\/","url":"https:\/\/data-flair.training\/blogs\/nodejs-mysql-tutorial\/","name":"Node.js MySQL Tutorial - DataFlair","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/#website"},"primaryImageOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/nodejs-mysql-tutorial\/#primaryimage"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/nodejs-mysql-tutorial\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/12\/nodejs-mysql.webp","datePublished":"2021-12-21T03:30:12+00:00","dateModified":"2021-12-21T05:33:02+00:00","description":"Learn about Node.js MySQL. Learn to install and connect MySQL to Nodejs, create database & table, insert in table, update & delete records etc","breadcrumb":{"@id":"https:\/\/data-flair.training\/blogs\/nodejs-mysql-tutorial\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/data-flair.training\/blogs\/nodejs-mysql-tutorial\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/data-flair.training\/blogs\/nodejs-mysql-tutorial\/#primaryimage","url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/12\/nodejs-mysql.webp","contentUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2021\/12\/nodejs-mysql.webp","width":1200,"height":628,"caption":"nodejs mysql"},{"@type":"BreadcrumbList","@id":"https:\/\/data-flair.training\/blogs\/nodejs-mysql-tutorial\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Blog Home","item":"https:\/\/data-flair.training\/blogs\/"},{"@type":"ListItem","position":2,"name":"Node Js Tutorials","item":"https:\/\/data-flair.training\/blogs\/category\/node-js-tutorials\/"},{"@type":"ListItem","position":3,"name":"Node.js MySQL Tutorial"}]},{"@type":"WebSite","@id":"https:\/\/data-flair.training\/blogs\/#website","url":"https:\/\/data-flair.training\/blogs\/","name":"DataFlair","description":"Learn Today. Lead Tomorrow.","publisher":{"@id":"https:\/\/data-flair.training\/blogs\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/data-flair.training\/blogs\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/data-flair.training\/blogs\/#organization","name":"DataFlair","url":"https:\/\/data-flair.training\/blogs\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/logo\/image\/","url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2016\/07\/Data-Flair.png","contentUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2016\/07\/Data-Flair.png","width":106,"height":48,"caption":"DataFlair"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/DataFlairWS\/","https:\/\/x.com\/DataFlairWS","https:\/\/www.linkedin.com\/company\/dataflair-web-services-pvt-ltd\/","https:\/\/www.youtube.com\/user\/DataFlairWS"]},{"@type":"Person","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/person\/7f83c342f5d1632d6f7b4b0b0f447823","name":"DataFlair Team","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/4cf3a74600d131330b8c481d519afd1574093ed89f6d3396a95393ad223eb7cd?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/4cf3a74600d131330b8c481d519afd1574093ed89f6d3396a95393ad223eb7cd?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/4cf3a74600d131330b8c481d519afd1574093ed89f6d3396a95393ad223eb7cd?s=96&d=mm&r=g","caption":"DataFlair Team"},"description":"DataFlair Team creates expert-level guides on programming, Java, Python, C++, DSA, AI, ML, data Science, Android, Flutter, MERN, Web Development, and technology. Our goal is to empower learners with easy-to-understand content. Explore our resources for career growth and practical learning.","url":"https:\/\/data-flair.training\/blogs\/author\/dfteam1\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/105009","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/comments?post=105009"}],"version-history":[{"count":2,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/105009\/revisions"}],"predecessor-version":[{"id":105041,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/105009\/revisions\/105041"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media\/105050"}],"wp:attachment":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media?parent=105009"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/categories?post=105009"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/tags?post=105009"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}