Hello, I imagined that my managed droplets will be easier to use but I’m getting errors on PostgreSQL and mySQL.
server.js
const http = require("http"), port = 8080;
const mysql = require("mysql")
const conn = mysql.createConnection({
host: "db-mysql-ams3-12003-do-user-4780354-0.db.ondigitalocean.com",
port: "25060",
user: "douser",
password: "p6ht9qa28lns7czv",
database: "defaultdb"
})
conn.connect(function(err){
if(err) console.log(err)
console.log("connected")
})
const requestHandler = (req, res) => {
const url = req.url.slice(4)
res.end(url)
}
const server = http.createServer(requestHandler)
server.listen(port)
ERROR
[user@centos api]$ node server
Error: ER_ACCESS_DENIED_ERROR: Access denied for user 'douser'@'165.22.204.96' (using password: YES)
at Handshake.Sequence._packetToError (/home/user/api/node_modules/mysql/lib/protocol/sequences/Sequence.js:47:14)
at Handshake.ErrorPacket (/home/user/api/node_modules/mysql/lib/protocol/sequences/Handshake.js:123:18)
at Protocol._parsePacket (/home/user/api/node_modules/mysql/lib/protocol/Protocol.js:291:23)
at Parser._parsePacket (/home/user/api/node_modules/mysql/lib/protocol/Parser.js:433:10)
at Parser.write (/home/user/api/node_modules/mysql/lib/protocol/Parser.js:43:10)
at Protocol.write (/home/user/api/node_modules/mysql/lib/protocol/Protocol.js:38:16)
at Socket.<anonymous> (/home/user/api/node_modules/mysql/lib/Connection.js:91:28)
at Socket.<anonymous> (/home/user/api/node_modules/mysql/lib/Connection.js:525:10)
at Socket.emit (events.js:210:5)
at addChunk (_stream_readable.js:308:12)
--------------------
at Protocol._enqueue (/home/user/api/node_modules/mysql/lib/protocol/Protocol.js:144:48)
at Protocol.handshake (/home/user/api/node_modules/mysql/lib/protocol/Protocol.js:51:23)
at Connection.connect (/home/user/api/node_modules/mysql/lib/Connection.js:119:18)
at Object.<anonymous> (/home/user/api/server.js:13:6)
at Module._compile (internal/modules/cjs/loader.js:956:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:973:10)
at Module.load (internal/modules/cjs/loader.js:812:32)
at Function.Module._load (internal/modules/cjs/loader.js:724:14)
at Function.Module.runMain (internal/modules/cjs/loader.js:1025:10)
at internal/main/run_main_module.js:17:11 {
code: 'ER_ACCESS_DENIED_ERROR',
errno: 1045,
sqlMessage: "Access denied for user 'douser'@'165.22.204.96' (using password: YES)",
sqlState: '28000',
fatal: true
}
connected
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Hello,
It looks like that your droplet’s IP is not added to your managed MySQL trusted source list.
You can follow the steps on how to add that here:
https://www.digitalocean.com/docs/databases/mysql/how-to/secure/
Hope that this helps! Regards, Bobby
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.