In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
Editor to share with you how to install nodejs mysql module, I believe that most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to understand it!
Nodejs install mysql module method: 1, open the cmd window, execute the "npm install-g cnpm" command to install cnpm tools; 2, use the cd command to enter the project directory, execute the "cnpm install mysql" command in the project to install the MySQL module.
The operating environment of this tutorial: windows7 system, nodejs 12.19.0, Dell G3 computer.
Node install and configure Mysql module ① install Mysql module
Cmd installs Taobao image
Npm install-g cnpm
Go to the project directory and install the MySQL module in the project
Cnpm install mysql ②. Configure environment variables
Add C:\ Program Files\ MySQL\ MySQL Server 8.0\ bin to the environment variable
Variable names can be picked up at will, such as mysql_home
The variable value is C:\ Program Files\ MySQL\ MySQL Server 8.0\ bin
3. Error
Client does not support authentication protocol requested by server
1. Enter the extracted mysql root directory (C:\ Program Files\ MySQL\ MySQL Server 8.0\ bin) through the command line.
2. Log in to the database
Mysql-u root-p
3. Enter the password of root
Enter password: *
4. Change the encryption method
Mysql > ALTER USER 'root'@'localhost' IDENTIFIED BY' password' PASSWORD EXPIRE NEVER
5. Change the password: 123456 in this example is the new password
Mysql > ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY' 123456'
6. Refresh:
Mysql > FLUSH PRIVILEGES; ④ .js file format var mysql = require ('mysql'); / / reference Mysql var connection = mysql.createConnection ({/ / configure connection host:' localhost',// database address user: "xxx", / / database user password: "xxx", / / database password database: "world" / / database to be connected}); connection.connect () / / Connect to the database connection.query ('select * from city',function (err,rows,fields) {/ / execute the sql statement if (err) throw err; console.log (' thesolution is:', rows [0]);}); connection.end (); / / disconnect all the contents of the article "how nodejs installs the mysql module". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.