Introduction
In order to connect to MySQL Database Server from a NodeJS application, there is a certain requirement to fulfill it. That requirement is the availability or the existence of MySQL modul in the NodeJS application. Actually, it is very simple to install an additional module in NodeJS application. For further reference, look an article with a similar content with the title of ‘How to Install mysql package using npm in Ubuntu Linux operating system’ in this link.
Installing MySQL Module in NodeJS Application
The following is the step for installing MySQL Module in a local NodeJS application :
1. First of all, just access the server or the machine. For an example, just directly access or remotely access. For further reference, an article with the title of ‘How to Remote CentOS Virtual Server running in a VirtualBox with a NAT Network using SSH’ in this link is explaining on how to remote a server or a machine. The demonstration for remote access target as an example in that article is a virtual server.
2. Apart from the operating system of the server, just access the command line interface exist in it.
3. Execute a command for installing module with the name of MySQL. Read an article with the title of ‘How to Install a Package using npm tool’ in this link for further reference on instaling NodeJS module. Another article with the title of ‘How to Install a Specific Package using npm via Command Line’ in this link. More article with similar content with the title of ‘How to Install Package using npm via Command Line’ exist in this link.
Furthermore, there is also an article with similar content in this link with the title of ‘How to Install Package Dependencies in Node.js Application using npm’. Another one is an article with the title of ‘How to Install a Specific Package using npm via Command Line’ in this link. All of those articles are available in the article contains all article links about NodeJS in this link with the title of ‘NodeJS Article’.
Just execute the following command :
[admin@10 nodejs]$ npm i mysql added 9 packages, and audited 208 packages in 3s 11 packages are looking for funding run `npm fund` for details found 0 vulnerabilities [admin@10 nodejs]$
4. Last but not least, execute the following command to check whether the MySQL module is available or not :
[admin@10 nodejs]$ npm list nodejs@ /home/admin/nodejs ├── [email protected] ├── [email protected] ├── [email protected] ├── [email protected] └── [email protected] [admin@10 nodejs]$
According to the output above, the MySQL module is already exist from the previous installation above.