{"id":5759,"date":"2017-06-14T23:52:03","date_gmt":"2017-06-15T06:52:03","guid":{"rendered":"http:\/\/www.mysqltutorial.org\/?page_id=5759"},"modified":"2024-01-03T17:39:16","modified_gmt":"2024-01-04T00:39:16","slug":"mysql-nodejs","status":"publish","type":"page","link":"https:\/\/www.mysqltutorial.org\/mysql-nodejs\/","title":{"rendered":"MySQL Node.js"},"content":{"rendered":"\n<p>Node.js offers several packages to interact with MySQL databases. One of the most popular packages is <a href=\"https:\/\/www.npmjs.com\/package\/mysql\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">mysql<\/a>.<\/p>\n\n\n\n<p>The <code>mysql<\/code> package facilitates the execution of SQL queries, allowing you access to MySQL seamlessly.  <\/p>\n\n\n\n<p>Whether you are developing API, server-side applications, or web applications, the mysql package simplifies database interactions using Node.js.<\/p>\n\n\n\n<p>In this tutorial series, you will learn how to master the <code>mysql<\/code> package from scratch. You will learn how to perform common operations including:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Connecting MySQL Server<\/li>\n\n\n\n<li>Creating a new table<\/li>\n\n\n\n<li>Inserting data into a table<\/li>\n\n\n\n<li>Querying data from a table<\/li>\n\n\n\n<li>Updating data<\/li>\n\n\n\n<li>Deleting data<\/li>\n\n\n\n<li>Calling a stored procedure<\/li>\n<\/ul>\n\n\n\n<p>After the tutorial, you will be able to develop the Node.js application using MySQL as the back-end database.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"645\" height=\"303\" src=\"https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2019\/09\/mysql-nodejs.png\" alt=\"\" class=\"wp-image-9078\" srcset=\"https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2019\/09\/mysql-nodejs.png 645w, https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2019\/09\/mysql-nodejs-200x94.png 200w\" sizes=\"auto, (max-width: 645px) 100vw, 645px\" \/><\/figure>\n<\/div>\n\n\n<div class=\"wp-block-group\"><div class=\"wp-block-group__inner-container is-layout-constrained wp-block-group-is-layout-constrained\">\n<h2 class=\"wp-block-heading\">Section 1. Getting Started<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/www.mysqltutorial.org\/mysql-nodejs\/connect\/\">Connecting to the MySQL Database Server from Node.js<\/a> &#8211; Connect to the MySQL database server from a node.js application using the mysql module API.<\/li>\n\n\n\n<li><a href=\"https:\/\/www.mysqltutorial.org\/mysql-nodejs\/create-table\/\">Creating Tables in MySQL from Node.js<\/a> &#8211; Create a new table in a MySQL database from a Node.js application using the mysql module.<\/li>\n<\/ul>\n<\/div><\/div>\n\n\n\n<div class=\"wp-block-group\"><div class=\"wp-block-group__inner-container is-layout-constrained wp-block-group-is-layout-constrained\">\n<h2 class=\"wp-block-heading\">Section 2. CRUD<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/www.mysqltutorial.org\/mysql-nodejs\/insert\/\">Inserting Rows Into a Table from Node.js<\/a> &#8211; Learn how to insert one or more rows into a table from the Node.js application.<\/li>\n\n\n\n<li><a href=\"https:\/\/www.mysqltutorial.org\/mysql-nodejs\/select\/\">Querying Data in MySQL Database from Node.js<\/a> &#8211; Query data from a table in the MySQL database from a Node.js application using the mysql module.<\/li>\n\n\n\n<li><a href=\"https:\/\/www.mysqltutorial.org\/mysql-nodejs\/update\/\">Updating Data in MySQL Database from Node.js<\/a> &#8211; Learn how to update data in the MySQL database from a Node.js application.<\/li>\n\n\n\n<li><a href=\"https:\/\/www.mysqltutorial.org\/mysql-nodejs\/delete\/\">Deleting Data in MySQL from Node.js<\/a> &#8211; Delete data in the MySQL database from a Node.js application.<\/li>\n<\/ul>\n<\/div><\/div>\n\n\n\n<div class=\"wp-block-group\"><div class=\"wp-block-group__inner-container is-layout-constrained wp-block-group-is-layout-constrained\">\n<h2 class=\"wp-block-heading\">Section 3. Stored Procedures<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/www.mysqltutorial.org\/mysql-nodejs\/connect\/\">Connecting to the MySQL Database Server from Node.js<\/a> &#8211; Connect to the MySQL database server from a node.js application using the mysql module API.<\/li>\n<\/ul>\n<\/div><\/div>\n","protected":false},"excerpt":{"rendered":"<p>In this section, you will learn how to interact with MySQL from node.js applications using the mysql module. <\/p>\n","protected":false},"author":2,"featured_media":10055,"parent":0,"menu_order":24,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-5759","page","type-page","status-publish","has-post-thumbnail","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>MySQL Node.js Tutorial<\/title>\n<meta name=\"description\" content=\"This tutorial shows you how to interact with MySQL from Node.js applications using the popular mysql package.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.mysqltutorial.org\/mysql-nodejs\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"MySQL Node.js Tutorial\" \/>\n<meta property=\"og:description\" content=\"This tutorial shows you how to interact with MySQL from Node.js applications using the popular mysql package.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.mysqltutorial.org\/mysql-nodejs\/\" \/>\n<meta property=\"og:site_name\" content=\"MySQL Tutorial\" \/>\n<meta property=\"article:modified_time\" content=\"2024-01-04T00:39:16+00:00\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.mysqltutorial.org\\\/mysql-nodejs\\\/\",\"url\":\"https:\\\/\\\/www.mysqltutorial.org\\\/mysql-nodejs\\\/\",\"name\":\"MySQL Node.js Tutorial\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.mysqltutorial.org\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.mysqltutorial.org\\\/mysql-nodejs\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.mysqltutorial.org\\\/mysql-nodejs\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.mysqltutorial.org\\\/wp-content\\\/uploads\\\/2021\\\/04\\\/mysql-nodejs.svg\",\"datePublished\":\"2017-06-15T06:52:03+00:00\",\"dateModified\":\"2024-01-04T00:39:16+00:00\",\"description\":\"This tutorial shows you how to interact with MySQL from Node.js applications using the popular mysql package.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.mysqltutorial.org\\\/mysql-nodejs\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.mysqltutorial.org\\\/mysql-nodejs\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.mysqltutorial.org\\\/mysql-nodejs\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.mysqltutorial.org\\\/wp-content\\\/uploads\\\/2021\\\/04\\\/mysql-nodejs.svg\",\"contentUrl\":\"https:\\\/\\\/www.mysqltutorial.org\\\/wp-content\\\/uploads\\\/2021\\\/04\\\/mysql-nodejs.svg\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.mysqltutorial.org\\\/mysql-nodejs\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.mysqltutorial.org\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"MySQL Node.js\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.mysqltutorial.org\\\/#website\",\"url\":\"https:\\\/\\\/www.mysqltutorial.org\\\/\",\"name\":\"MySQL Tutorial\",\"description\":\"A comprehensive MySQL Tutorial\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.mysqltutorial.org\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"MySQL Node.js Tutorial","description":"This tutorial shows you how to interact with MySQL from Node.js applications using the popular mysql package.","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:\/\/www.mysqltutorial.org\/mysql-nodejs\/","og_locale":"en_US","og_type":"article","og_title":"MySQL Node.js Tutorial","og_description":"This tutorial shows you how to interact with MySQL from Node.js applications using the popular mysql package.","og_url":"https:\/\/www.mysqltutorial.org\/mysql-nodejs\/","og_site_name":"MySQL Tutorial","article_modified_time":"2024-01-04T00:39:16+00:00","twitter_misc":{"Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.mysqltutorial.org\/mysql-nodejs\/","url":"https:\/\/www.mysqltutorial.org\/mysql-nodejs\/","name":"MySQL Node.js Tutorial","isPartOf":{"@id":"https:\/\/www.mysqltutorial.org\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.mysqltutorial.org\/mysql-nodejs\/#primaryimage"},"image":{"@id":"https:\/\/www.mysqltutorial.org\/mysql-nodejs\/#primaryimage"},"thumbnailUrl":"https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2021\/04\/mysql-nodejs.svg","datePublished":"2017-06-15T06:52:03+00:00","dateModified":"2024-01-04T00:39:16+00:00","description":"This tutorial shows you how to interact with MySQL from Node.js applications using the popular mysql package.","breadcrumb":{"@id":"https:\/\/www.mysqltutorial.org\/mysql-nodejs\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.mysqltutorial.org\/mysql-nodejs\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.mysqltutorial.org\/mysql-nodejs\/#primaryimage","url":"https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2021\/04\/mysql-nodejs.svg","contentUrl":"https:\/\/www.mysqltutorial.org\/wp-content\/uploads\/2021\/04\/mysql-nodejs.svg"},{"@type":"BreadcrumbList","@id":"https:\/\/www.mysqltutorial.org\/mysql-nodejs\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.mysqltutorial.org\/"},{"@type":"ListItem","position":2,"name":"MySQL Node.js"}]},{"@type":"WebSite","@id":"https:\/\/www.mysqltutorial.org\/#website","url":"https:\/\/www.mysqltutorial.org\/","name":"MySQL Tutorial","description":"A comprehensive MySQL Tutorial","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.mysqltutorial.org\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"}]}},"_links":{"self":[{"href":"https:\/\/www.mysqltutorial.org\/wp-json\/wp\/v2\/pages\/5759","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.mysqltutorial.org\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.mysqltutorial.org\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.mysqltutorial.org\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.mysqltutorial.org\/wp-json\/wp\/v2\/comments?post=5759"}],"version-history":[{"count":4,"href":"https:\/\/www.mysqltutorial.org\/wp-json\/wp\/v2\/pages\/5759\/revisions"}],"predecessor-version":[{"id":14082,"href":"https:\/\/www.mysqltutorial.org\/wp-json\/wp\/v2\/pages\/5759\/revisions\/14082"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.mysqltutorial.org\/wp-json\/wp\/v2\/media\/10055"}],"wp:attachment":[{"href":"https:\/\/www.mysqltutorial.org\/wp-json\/wp\/v2\/media?parent=5759"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}