Skip to content

Commit 00f6436

Browse files
committed
Update mysql npm package to mysql2 in single server docs
1 parent 3f68a8e commit 00f6436

File tree

1 file changed

+19
-19
lines changed

1 file changed

+19
-19
lines changed

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)