Skip to content

Commit 3f68a8e

Browse files
committed
Update mysql npm package to mysql2
1 parent 1c7f448 commit 3f68a8e

File tree

1 file changed

+22
-22
lines changed

1 file changed

+22
-22
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 =

0 commit comments

Comments
 (0)