You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/mysql/flexible-server/connect-nodejs.md
+22-22Lines changed: 22 additions & 22 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,10 +1,10 @@
1
1
---
2
2
title: "Quickstart: Connect using Node.js - Azure Database for MySQL - Flexible Server"
3
3
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
6
6
ms.reviewer: maghan
7
-
ms.date: 05/03/2023
7
+
ms.date: 06/19/2023
8
8
ms.service: mysql
9
9
ms.subservice: flexible-server
10
10
ms.topic: quickstart
@@ -37,18 +37,18 @@ This quickstart uses the resources created in either of these guides as a starti
37
37
38
38
## Install Node.js and the MySQL connector
39
39
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.
41
41
42
42
### [Windows](#tab/windows)
43
43
44
44
1. Visit the [Node.js downloads page](https://nodejs.org/en/download/), and then select your desired Windows installer option.
45
45
1. Make a local project folder such as `nodejsmysql`.
46
46
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.
48
48
49
49
```cmd
50
50
cd c:\nodejsmysql\
51
-
"C:\Program Files\nodejs\npm" install mysql
51
+
"C:\Program Files\nodejs\npm" install mysql2
52
52
"C:\Program Files\nodejs\npm" list
53
53
```
54
54
@@ -68,12 +68,12 @@ Depending on your platform, follow the instructions in the appropriate section t
68
68
sudo apt-get install -y nodejs
69
69
```
70
70
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.
72
72
73
73
```bash
74
74
mkdir nodejsmysql
75
75
cd nodejsmysql
76
-
npm install --save mysql
76
+
npm install --save mysql2
77
77
npm list
78
78
```
79
79
@@ -96,12 +96,12 @@ Depending on your platform, follow the instructions in the appropriate section t
96
96
sudo yum install -y nodejs
97
97
```
98
98
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.
100
100
101
101
```bash
102
102
mkdir nodejsmysql
103
103
cd nodejsmysql
104
-
npm install --save mysql
104
+
npm install --save mysql2
105
105
npm list
106
106
```
107
107
@@ -115,12 +115,12 @@ Depending on your platform, follow the instructions in the appropriate section t
115
115
sudo zypper install nodejs
116
116
```
117
117
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.
119
119
120
120
```bash
121
121
mkdir nodejsmysql
122
122
cd nodejsmysql
123
-
npm install --save mysql
123
+
npm install --save mysql2
124
124
npm list
125
125
```
126
126
@@ -130,12 +130,12 @@ Depending on your platform, follow the instructions in the appropriate section t
130
130
131
131
1. Visit the [Node.js downloads page](https://nodejs.org/en/download/), and then select your macOS installer.
132
132
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.
134
134
135
135
```bash
136
136
mkdir nodejsmysql
137
137
cd nodejsmysql
138
-
npm install --save mysql
138
+
npm install --save mysql2
139
139
npm list
140
140
```
141
141
@@ -170,10 +170,10 @@ Save the certificate file to your preferred location.
170
170
171
171
Use the following code to connect and load the data by using **CREATE TABLE** and **INSERT INTO** SQL statements.
172
172
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.
174
174
175
175
```javascript
176
-
constmysql=require('mysql');
176
+
constmysql=require('mysql2');
177
177
constfs=require('fs');
178
178
179
179
var config =
@@ -244,10 +244,10 @@ function queryDatabase()
244
244
245
245
Use the following code to connect and read the data by using a **SELECT** SQL statement.
246
246
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.
248
248
249
249
```javascript
250
-
constmysql=require('mysql');
250
+
constmysql=require('mysql2');
251
251
constfs=require('fs');
252
252
253
253
var config =
@@ -296,10 +296,10 @@ function readData(){
296
296
297
297
Use the following code to connect and update the data by using an **UPDATE** SQL statement.
298
298
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.
300
300
301
301
```javascript
302
-
constmysql=require('mysql');
302
+
constmysql=require('mysql2');
303
303
constfs=require('fs');
304
304
305
305
var config =
@@ -344,10 +344,10 @@ function updateData(){
344
344
345
345
Use the following code to connect and delete data by using a **DELETE** SQL statement.
346
346
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.
Copy file name to clipboardExpand all lines: articles/mysql/single-server/connect-nodejs.md
+19-19Lines changed: 19 additions & 19 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -31,18 +31,18 @@ This article assumes that you're familiar with developing using Node.js, but you
31
31
32
32
## Install Node.js and the MySQL connector
33
33
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.
35
35
36
36
### [Windows](#tab/windows)
37
37
38
38
1. Visit the [Node.js downloads page](https://nodejs.org/en/download/), and then select your desired Windows installer option.
39
39
2. Make a local project folder such as `nodejsmysql`.
40
40
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.
42
42
43
43
```cmd
44
44
cd c:\nodejsmysql\
45
-
"C:\Program Files\nodejs\npm" install mysql
45
+
"C:\Program Files\nodejs\npm" install mysql2
46
46
"C:\Program Files\nodejs\npm" list
47
47
```
48
48
@@ -62,12 +62,12 @@ Depending on your platform, follow the instructions in the appropriate section t
62
62
sudo apt-get install -y nodejs
63
63
```
64
64
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.
66
66
67
67
```bash
68
68
mkdir nodejsmysql
69
69
cd nodejsmysql
70
-
npm install --save mysql
70
+
npm install --save mysql2
71
71
npm list
72
72
```
73
73
@@ -90,12 +90,12 @@ Depending on your platform, follow the instructions in the appropriate section t
90
90
sudo yum install -y nodejs
91
91
```
92
92
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.
94
94
95
95
```bash
96
96
mkdir nodejsmysql
97
97
cd nodejsmysql
98
-
npm install --save mysql
98
+
npm install --save mysql2
99
99
npm list
100
100
```
101
101
@@ -109,12 +109,12 @@ Depending on your platform, follow the instructions in the appropriate section t
109
109
sudo zypper install nodejs
110
110
```
111
111
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.
113
113
114
114
```bash
115
115
mkdir nodejsmysql
116
116
cd nodejsmysql
117
-
npm install --save mysql
117
+
npm install --save mysql2
118
118
npm list
119
119
```
120
120
@@ -124,12 +124,12 @@ Depending on your platform, follow the instructions in the appropriate section t
124
124
125
125
1. Visit the [Node.js downloads page](https://nodejs.org/en/download/), and then select your macOS installer.
126
126
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.
128
128
129
129
```bash
130
130
mkdir nodejsmysql
131
131
cd nodejsmysql
132
-
npm install --save mysql
132
+
npm install --save mysql2
133
133
npm list
134
134
```
135
135
@@ -165,10 +165,10 @@ Get the connection information needed to connect to the Azure Database for MySQL
165
165
166
166
Use the following code to connect and load the data by using **CREATE TABLE** and **INSERT INTO** SQL statements.
167
167
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.
169
169
170
170
```javascript
171
-
constmysql=require('mysql');
171
+
constmysql=require('mysql2');
172
172
constfs=require('fs');
173
173
174
174
var config =
@@ -232,10 +232,10 @@ function queryDatabase(){
232
232
233
233
Use the following code to connect and read the data by using a **SELECT** SQL statement.
234
234
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.
236
236
237
237
```javascript
238
-
constmysql=require('mysql');
238
+
constmysql=require('mysql2');
239
239
constfs=require('fs');
240
240
241
241
var config =
@@ -284,10 +284,10 @@ function readData(){
284
284
285
285
Use the following code to connect and update data by using an **UPDATE** SQL statement.
286
286
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.
288
288
289
289
```javascript
290
-
constmysql=require('mysql');
290
+
constmysql=require('mysql2');
291
291
constfs=require('fs');
292
292
293
293
var config =
@@ -332,10 +332,10 @@ function updateData(){
332
332
333
333
Use the following code to connect and delete data by using a **DELETE** SQL statement.
334
334
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.
0 commit comments