Skip to content

Commit 9d02c6f

Browse files
Merge pull request #241926 from shreyaaithal/nodejs-quickstarts
Update node.js quickstarts
2 parents c45cff6 + 00f6436 commit 9d02c6f

File tree

2 files changed

+41
-41
lines changed

2 files changed

+41
-41
lines changed

articles/mysql/flexible-server/connect-nodejs.md

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
---
22
title: "Quickstart: Connect using Node.js - Azure Database for MySQL - Flexible Server"
33
description: This quickstart provides several Node.js code samples you can use to connect and query data from Azure Database for MySQL - Flexible Server.
4-
author: code-sidd
5-
ms.author: sisawant
4+
author: shreyaaithal
5+
ms.author: shaithal
66
ms.reviewer: maghan
7-
ms.date: 05/03/2023
7+
ms.date: 06/19/2023
88
ms.service: mysql
99
ms.subservice: flexible-server
1010
ms.topic: quickstart
@@ -37,18 +37,18 @@ This quickstart uses the resources created in either of these guides as a starti
3737
3838
## Install Node.js and the MySQL connector
3939

40-
Depending on your platform, follow the instructions in the appropriate section to install [Node.js](https://nodejs.org). Use npm to install the [mysql](https://www.npmjs.com/package/mysql) package and its dependencies into your project folder.
40+
Depending on your platform, follow the instructions in the appropriate section to install [Node.js](https://nodejs.org). Use npm to install the [mysql2](https://www.npmjs.com/package/mysql2) package and its dependencies into your project folder.
4141

4242
### [Windows](#tab/windows)
4343

4444
1. Visit the [Node.js downloads page](https://nodejs.org/en/download/), and then select your desired Windows installer option.
4545
1. Make a local project folder such as `nodejsmysql`.
4646
1. Open the command prompt, and then change directory into the project folder, such as `cd c:\nodejsmysql\`
47-
1. Run the NPM tool to install the mysql library into the project folder.
47+
1. Run the NPM tool to install mysql2 library into the project folder.
4848

4949
```cmd
5050
cd c:\nodejsmysql\
51-
"C:\Program Files\nodejs\npm" install mysql
51+
"C:\Program Files\nodejs\npm" install mysql2
5252
"C:\Program Files\nodejs\npm" list
5353
```
5454
@@ -68,12 +68,12 @@ Depending on your platform, follow the instructions in the appropriate section t
6868
sudo apt-get install -y nodejs
6969
```
7070

71-
1. Run the following commands to create a project folder `mysqlnodejs` and install the mysql package into that folder.
71+
1. Run the following commands to create a project folder `mysqlnodejs` and install the mysql2 package into that folder.
7272

7373
```bash
7474
mkdir nodejsmysql
7575
cd nodejsmysql
76-
npm install --save mysql
76+
npm install --save mysql2
7777
npm list
7878
```
7979

@@ -96,12 +96,12 @@ Depending on your platform, follow the instructions in the appropriate section t
9696
sudo yum install -y nodejs
9797
```
9898

99-
1. Run the following commands to create a project folder `mysqlnodejs` and install the mysql package into that folder.
99+
1. Run the following commands to create a project folder `mysqlnodejs` and install the mysql2 package into that folder.
100100

101101
```bash
102102
mkdir nodejsmysql
103103
cd nodejsmysql
104-
npm install --save mysql
104+
npm install --save mysql2
105105
npm list
106106
```
107107

@@ -115,12 +115,12 @@ Depending on your platform, follow the instructions in the appropriate section t
115115
sudo zypper install nodejs
116116
```
117117

118-
1. Run the following commands to create a project folder `mysqlnodejs` and install the mysql package into that folder.
118+
1. Run the following commands to create a project folder `mysqlnodejs` and install the mysql2 package into that folder.
119119

120120
```bash
121121
mkdir nodejsmysql
122122
cd nodejsmysql
123-
npm install --save mysql
123+
npm install --save mysql2
124124
npm list
125125
```
126126

@@ -130,12 +130,12 @@ Depending on your platform, follow the instructions in the appropriate section t
130130

131131
1. Visit the [Node.js downloads page](https://nodejs.org/en/download/), and then select your macOS installer.
132132

133-
1. Run the following commands to create a project folder `mysqlnodejs` and install the mysql package into that folder.
133+
1. Run the following commands to create a project folder `mysqlnodejs` and install the mysql2 package into that folder.
134134

135135
```bash
136136
mkdir nodejsmysql
137137
cd nodejsmysql
138-
npm install --save mysql
138+
npm install --save mysql2
139139
npm list
140140
```
141141

@@ -170,10 +170,10 @@ Save the certificate file to your preferred location.
170170

171171
Use the following code to connect and load the data by using **CREATE TABLE** and **INSERT INTO** SQL statements.
172172

173-
The [mysql.createConnection()](https://github.com/mysqljs/mysql#establishing-connections) method is used to interface with the MySQL server. The [connect()](https://github.com/mysqljs/mysql#establishing-connections) function is used to establish the connection to the server. The [query()](https://github.com/mysqljs/mysql#performing-queries) function is used to execute the SQL query against MySQL database.
173+
The [mysql.createConnection()](https://github.com/sidorares/node-mysql2#first-query) method is used to interface with the MySQL server. The [connect()](https://github.com/sidorares/node-mysql2#first-query) function is used to establish the connection to the server. The [query()](https://github.com/sidorares/node-mysql2#first-query) function is used to execute the SQL query against MySQL database.
174174

175175
```javascript
176-
const mysql = require('mysql');
176+
const mysql = require('mysql2');
177177
const fs = require('fs');
178178

179179
var config =
@@ -244,10 +244,10 @@ function queryDatabase()
244244

245245
Use the following code to connect and read the data by using a **SELECT** SQL statement.
246246

247-
The [mysql.createConnection()](https://github.com/mysqljs/mysql#establishing-connections) method is used to interface with the MySQL server. The [connect()](https://github.com/mysqljs/mysql#establishing-connections) method is used to establish the connection to the server. The [query()](https://github.com/mysqljs/mysql#performing-queries) method is used to execute the SQL query against MySQL database. The results array is used to hold the results of the query.
247+
The [mysql.createConnection()](https://github.com/sidorares/node-mysql2#first-query) method is used to interface with the MySQL server. The [connect()](https://github.com/sidorares/node-mysql2#first-query) method is used to establish the connection to the server. The [query()](https://github.com/sidorares/node-mysql2#first-query) method is used to execute the SQL query against MySQL database. The results array is used to hold the results of the query.
248248

249249
```javascript
250-
const mysql = require('mysql');
250+
const mysql = require('mysql2');
251251
const fs = require('fs');
252252

253253
var config =
@@ -296,10 +296,10 @@ function readData(){
296296

297297
Use the following code to connect and update the data by using an **UPDATE** SQL statement.
298298

299-
The [mysql.createConnection()](https://github.com/mysqljs/mysql#establishing-connections) method is used to interface with the MySQL server. The [connect()](https://github.com/mysqljs/mysql#establishing-connections) method is used to establish the connection to the server. The [query()](https://github.com/mysqljs/mysql#performing-queries) method is used to execute the SQL query against MySQL database.
299+
The [mysql.createConnection()](https://github.com/sidorares/node-mysql2#first-query) method is used to interface with the MySQL server. The [connect()](https://github.com/sidorares/node-mysql2#first-query) method is used to establish the connection to the server. The [query()](https://github.com/sidorares/node-mysql2#first-query) method is used to execute the SQL query against MySQL database.
300300

301301
```javascript
302-
const mysql = require('mysql');
302+
const mysql = require('mysql2');
303303
const fs = require('fs');
304304

305305
var config =
@@ -344,10 +344,10 @@ function updateData(){
344344

345345
Use the following code to connect and delete data by using a **DELETE** SQL statement.
346346

347-
The [mysql.createConnection()](https://github.com/mysqljs/mysql#establishing-connections) method is used to interface with the MySQL server. The [connect()](https://github.com/mysqljs/mysql#establishing-connections) method is used to establish the connection to the server. The [query()](https://github.com/mysqljs/mysql#performing-queries) method is used to execute the SQL query against MySQL database.
347+
The [mysql.createConnection()](https://github.com/sidorares/node-mysql2#first-query) method is used to interface with the MySQL server. The [connect()](https://github.com/sidorares/node-mysql2#first-query) method is used to establish the connection to the server. The [query()](https://github.com/sidorares/node-mysql2#first-query) method is used to execute the SQL query against MySQL database.
348348

349349
```javascript
350-
const mysql = require('mysql');
350+
const mysql = require('mysql2');
351351
const fs = require('fs');
352352

353353
var config =

articles/mysql/single-server/connect-nodejs.md

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -31,18 +31,18 @@ This article assumes that you're familiar with developing using Node.js, but you
3131
3232
## Install Node.js and the MySQL connector
3333

34-
Depending on your platform, follow the instructions in the appropriate section to install [Node.js](https://nodejs.org). Use npm to install the [mysql](https://www.npmjs.com/package/mysql) package and its dependencies into your project folder.
34+
Depending on your platform, follow the instructions in the appropriate section to install [Node.js](https://nodejs.org). Use npm to install the [mysql2](https://www.npmjs.com/package/mysql2) package and its dependencies into your project folder.
3535

3636
### [Windows](#tab/windows)
3737

3838
1. Visit the [Node.js downloads page](https://nodejs.org/en/download/), and then select your desired Windows installer option.
3939
2. Make a local project folder such as `nodejsmysql`.
4040
3. Open the command prompt, and then change directory into the project folder, such as `cd c:\nodejsmysql\`
41-
4. Run the NPM tool to install the mysql library into the project folder.
41+
4. Run the NPM tool to install the mysql2 library into the project folder.
4242

4343
```cmd
4444
cd c:\nodejsmysql\
45-
"C:\Program Files\nodejs\npm" install mysql
45+
"C:\Program Files\nodejs\npm" install mysql2
4646
"C:\Program Files\nodejs\npm" list
4747
```
4848

@@ -62,12 +62,12 @@ Depending on your platform, follow the instructions in the appropriate section t
6262
sudo apt-get install -y nodejs
6363
```
6464

65-
2. Run the following commands to create a project folder `mysqlnodejs` and install the mysql package into that folder.
65+
2. Run the following commands to create a project folder `mysqlnodejs` and install the mysql2 package into that folder.
6666

6767
```bash
6868
mkdir nodejsmysql
6969
cd nodejsmysql
70-
npm install --save mysql
70+
npm install --save mysql2
7171
npm list
7272
```
7373

@@ -90,12 +90,12 @@ Depending on your platform, follow the instructions in the appropriate section t
9090
sudo yum install -y nodejs
9191
```
9292

93-
1. Run the following commands to create a project folder `mysqlnodejs` and install the mysql package into that folder.
93+
1. Run the following commands to create a project folder `mysqlnodejs` and install the mysql2 package into that folder.
9494

9595
```bash
9696
mkdir nodejsmysql
9797
cd nodejsmysql
98-
npm install --save mysql
98+
npm install --save mysql2
9999
npm list
100100
```
101101

@@ -109,12 +109,12 @@ Depending on your platform, follow the instructions in the appropriate section t
109109
sudo zypper install nodejs
110110
```
111111

112-
1. Run the following commands to create a project folder `mysqlnodejs` and install the mysql package into that folder.
112+
1. Run the following commands to create a project folder `mysqlnodejs` and install the mysql2 package into that folder.
113113

114114
```bash
115115
mkdir nodejsmysql
116116
cd nodejsmysql
117-
npm install --save mysql
117+
npm install --save mysql2
118118
npm list
119119
```
120120

@@ -124,12 +124,12 @@ Depending on your platform, follow the instructions in the appropriate section t
124124

125125
1. Visit the [Node.js downloads page](https://nodejs.org/en/download/), and then select your macOS installer.
126126

127-
2. Run the following commands to create a project folder `mysqlnodejs` and install the mysql package into that folder.
127+
2. Run the following commands to create a project folder `mysqlnodejs` and install the mysql2 package into that folder.
128128

129129
```bash
130130
mkdir nodejsmysql
131131
cd nodejsmysql
132-
npm install --save mysql
132+
npm install --save mysql2
133133
npm list
134134
```
135135

@@ -165,10 +165,10 @@ Get the connection information needed to connect to the Azure Database for MySQL
165165

166166
Use the following code to connect and load the data by using **CREATE TABLE** and **INSERT INTO** SQL statements.
167167

168-
The [mysql.createConnection()](https://github.com/mysqljs/mysql#establishing-connections) method is used to interface with the MySQL server. The [connect()](https://github.com/mysqljs/mysql#establishing-connections) function is used to establish the connection to the server. The [query()](https://github.com/mysqljs/mysql#performing-queries) function is used to execute the SQL query against MySQL database.
168+
The [mysql.createConnection()](https://github.com/sidorares/node-mysql2#first-query) method is used to interface with the MySQL server. The [connect()](https://github.com/sidorares/node-mysql2#first-query) function is used to establish the connection to the server. The [query()](https://github.com/sidorares/node-mysql2#first-query) function is used to execute the SQL query against MySQL database.
169169

170170
```javascript
171-
const mysql = require('mysql');
171+
const mysql = require('mysql2');
172172
const fs = require('fs');
173173

174174
var config =
@@ -232,10 +232,10 @@ function queryDatabase(){
232232

233233
Use the following code to connect and read the data by using a **SELECT** SQL statement.
234234

235-
The [mysql.createConnection()](https://github.com/mysqljs/mysql#establishing-connections) method is used to interface with the MySQL server. The [connect()](https://github.com/mysqljs/mysql#establishing-connections) method is used to establish the connection to the server. The [query()](https://github.com/mysqljs/mysql#performing-queries) method is used to execute the SQL query against MySQL database. The results array is used to hold the results of the query.
235+
The [mysql.createConnection()](https://github.com/sidorares/node-mysql2#first-query) method is used to interface with the MySQL server. The [connect()](https://github.com/sidorares/node-mysql2#first-query) method is used to establish the connection to the server. The [query()](https://github.com/sidorares/node-mysql2#first-query) method is used to execute the SQL query against MySQL database. The results array is used to hold the results of the query.
236236

237237
```javascript
238-
const mysql = require('mysql');
238+
const mysql = require('mysql2');
239239
const fs = require('fs');
240240

241241
var config =
@@ -284,10 +284,10 @@ function readData(){
284284

285285
Use the following code to connect and update data by using an **UPDATE** SQL statement.
286286

287-
The [mysql.createConnection()](https://github.com/mysqljs/mysql#establishing-connections) method is used to interface with the MySQL server. The [connect()](https://github.com/mysqljs/mysql#establishing-connections) method is used to establish the connection to the server. The [query()](https://github.com/mysqljs/mysql#performing-queries) method is used to execute the SQL query against MySQL database.
287+
The [mysql.createConnection()](https://github.com/sidorares/node-mysql2#first-query) method is used to interface with the MySQL server. The [connect()](https://github.com/sidorares/node-mysql2#first-query) method is used to establish the connection to the server. The [query()](https://github.com/sidorares/node-mysql2#first-query) method is used to execute the SQL query against MySQL database.
288288

289289
```javascript
290-
const mysql = require('mysql');
290+
const mysql = require('mysql2');
291291
const fs = require('fs');
292292

293293
var config =
@@ -332,10 +332,10 @@ function updateData(){
332332

333333
Use the following code to connect and delete data by using a **DELETE** SQL statement.
334334

335-
The [mysql.createConnection()](https://github.com/mysqljs/mysql#establishing-connections) method is used to interface with the MySQL server. The [connect()](https://github.com/mysqljs/mysql#establishing-connections) method is used to establish the connection to the server. The [query()](https://github.com/mysqljs/mysql#performing-queries) method is used to execute the SQL query against MySQL database.
335+
The [mysql.createConnection()](https://github.com/sidorares/node-mysql2#first-query) method is used to interface with the MySQL server. The [connect()](https://github.com/sidorares/node-mysql2#first-query) method is used to establish the connection to the server. The [query()](https://github.com/sidorares/node-mysql2#first-query) method is used to execute the SQL query against MySQL database.
336336

337337
```javascript
338-
const mysql = require('mysql');
338+
const mysql = require('mysql2');
339339
const fs = require('fs');
340340

341341
var config =

0 commit comments

Comments
 (0)