PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Thursday, February 3, 2022

[FIXED] I am not able connect Node.js project with Mamp dadabase

 February 03, 2022     database, mamp, mysql, node.js     No comments   

Issue

Hi I am using below code to connect with Mamp data base "http://localhost:8888/phpMyAdmin/server_databases.php?server=1" but not able to do it getting below error

code :-

const db = mysql.createConnection({
    host: 'localhost',
    user: 'root',
    password: 'root',
    database: 'nodejs.login',
})

db.connect((error) =>{
    if(error){
        console.log(error)
    }else {
        console.log("Mysql Connected....")
    }
    
})

error:-

server startwd on Port 5003
{ Error: connect ECONNREFUSED 127.0.0.1:3306
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1117:14)
    --------------------
    at Protocol._enqueue (/Users/ruchir/Documents/Assesment_Node/node_modules/mysql/lib/protocol/Protocol.js:144:48)
    at Protocol.handshake (/Users/ruchir/Documents/Assesment_Node/node_modules/mysql/lib/protocol/Protocol.js:51:23)
    at Connection.connect (/Users/ruchir/Documents/Assesment_Node/node_modules/mysql/lib/Connection.js:116:18)
    at Object.<anonymous> (/Users/ruchir/Documents/Assesment_Node/app.js:13:4)
    at Module._compile (internal/modules/cjs/loader.js:689:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
    at Module.load (internal/modules/cjs/loader.js:599:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
    at Function.Module._load (internal/modules/cjs/loader.js:530:3)
    at Function.Module.runMain (internal/modules/cjs/loader.js:742:12)
  errno: 'ECONNREFUSED',
  code: 'ECONNREFUSED',
  syscall: 'connect',
  address: '127.0.0.1',
  port: 3306,
  fatal: true }



Solution

I am able to resolve it.i have check and find my Mamp server was running on 8889 so i have added one more variable in connetion port: '8889' at it works.



Answered By - jugal
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing