1.cmd管理员进入mysql文件夹的bin目录
2.键入命令行 mysql -u -root -p
3.输入密码
4. alter USER ‘root‘@‘localhost‘ IDENTIFIED BY ‘password‘ PASSWORD EXPIRENEVER; (必填)
5.alter USER ‘root‘@‘localhost‘ IDENTIFIED WITH mysql_native_password BY ‘password‘;(修改自己的密码)
6.FLUSH PRIVILEGES;(刷新权限)
7.完成
8.npm install mysql
9.编写一套简单的查询 mysql.js
var mysql = require(‘mysql‘); var connection = mysql.createConnection({ host: "127.0.0.1", user: "root", password: "123456", port: ‘3306‘, database: ‘test‘ }); connection.connect(); connection.query(‘select * from user‘,function(error, results, fields){ if(error) throw error; console.log("这是结果:"+JSON.stringify(results)) }); connection.end();
原文地址:https://www.cnblogs.com/GeekXwj/p/10339796.html
时间: 2024-11-08 13:02:33