简体   繁体   English

当我尝试测试运行我的 MySQL 数据库时收到此错误消息

[英]I get this error message when I try to test run my MySQL database

this is my database code这是我的数据库代码



var con = mysql.createConnection({
  host: "localhost",
  user: "root",
  password: "",
  port: "889", 
});

con.connect(function(err) {
  if (err) throw err;
  console.log("Connected!");
  con.query("CREATE DATABASE mydb", function (err, result) {
    if (err) throw err;
    console.log("Database created");
  });  
});

and this is the error I get when trying to run it in my terminal window这是我尝试在终端 window 中运行它时遇到的错误

  if (err) throw err;
           ^

Error: connect ECONNREFUSED 127.0.0.1:889
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1141:16)
    --------------------
    at Protocol._enqueue (C:\Users\Amman\dunder-mifflin\node_modules\mysql\lib\protocol\Protocol.js:144:48)
    at Protocol.handshake (C:\Users\Amman\dunder-mifflin\node_modules\mysql\lib\protocol\Protocol.js:51:23)
    at Connection.connect (C:\Users\Amman\dunder-mifflin\node_modules\mysql\lib\Connection.js:116:18)
    at Object.<anonymous> (C:\Users\Amman\dunder-mifflin\src\database\database.js:11:5)
    at Module._compile (internal/modules/cjs/loader.js:1137:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10)
    at Module.load (internal/modules/cjs/loader.js:985:32)
    at Function.Module._load (internal/modules/cjs/loader.js:878:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
    at internal/main/run_main_module.js:17:47 {
  errno: 'ECONNREFUSED',
  code: 'ECONNREFUSED',
  syscall: 'connect',
  address: '127.0.0.1',
  port: 889,
  fatal: true
}

I tried looking up problems on the internet but I still don't know why I'm getting this error.我尝试在互联网上查找问题,但我仍然不知道为什么会出现此错误。

Like the person in the comments said:就像评论里的人说的:

var con = mysql.createConnection({
  host: "localhost",
  user: "root",
  password: "",
  port: "889", 
});

Is the wrong port number if you have other processes running on the same port SQL will not work usually people use:如果您在同一端口上运行其他进程 SQL 将无法正常工作,那么端口号是否错误通常人们使用:

var con = mysql.createConnection({
  host: "localhost",
  user: "root",
  password: "",
  port: "3306", 
});

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 开玩笑时出现错误,我尝试运行测试 - Error on jest when I try to run the test 当我尝试在Couchbase Node.js服务器上运行简单测试时,出现“参数错误”错误 - I get “Incorrect argument” error when i try to run a simple test on couchbase nodejs server UnhandledPromiseRejectionWarning:错误:当我尝试运行我的代码时找不到模块“../database/db” - UnhandledPromiseRejectionWarning: Error: Cannot find module '../database/db' when i try to run my code 当我尝试在Heroku上使用PGSQL更新数据库时,出现22001错误 - When I try to update my database with PGSQL on Heroku, I get a 22001 error 每当我尝试在 VScode 终端中运行 cypress run --record --key xxxx 时,都会收到一条错误消息 - I get an error message whenever I try to run the cypress run --record --key xxxx in VScode terminal 当我尝试在我的 React 应用程序中运行 npm 测试时出现错误“SyntaxError: Cannot use import statement outside a module” - The error "SyntaxError: Cannot use import statement outside a module" appears when I try to run npm test in my react application 运行测试时出现错误消息? - I have an error message when running my test? 为什么当我尝试运行服务器 gRPC 时出现此错误? - why i'm i getting this error when i try to run my server gRPC? 当我尝试运行我的 React 项目时出现错误 - I am getting an error when I try to run my react project 当我尝试连接到我的数据库 nodejs 时,我收到一个未知的数据库错误 - Im getting a unknown database error when i try to connect to my database nodejs
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM