0

I am using azure connection string (from Azure portal) for Node.js app, still cannot connect to Azure Database for Mysql server.

var conn = mysql.createConnection({ host: yourhost, user: "username", password: "password", database: "database", port: 3306, ssl:{ca:fs.readFileSync(__dirname + '/baltimore.pem')}});

I get following error: "Error: MySQL server is requesting the old and insecure pre-4.1 auth mechanism.Upgrade the user password or use the {insecureAuth: true} option."

But I can connect using Mysql Benchmark same credentials.

What I am doing wrong ?

Eric_Zhang
  • 85
  • 5

1 Answers1

0

Azure Database for MySQL is incompatible with the mysqljs connector library. See issue 1729 for details and pull 1730 for a workaround.

Bradley Grainger
  • 27,458
  • 4
  • 91
  • 108
  • Thanks for an answer, now it gives an error : \lib\protocol\Parser.js:80 throw err; // Rethrow non-MySQL errors ^ Error: Can't set headers after they are sent. at ServerResponse.OutgoingMessage.setHeader (_http_outgoing.js:344:11) – Ruslan Safarov May 28 '17 at 20:47
  • @RuslanSafarov That looks like an error with whatever HTTP library you are using; once the HTTP headers have been sent to the client, they can't be modified. – Bradley Grainger May 28 '17 at 20:50
  • I am using standart http and Express. I was using createPool, now when I use createConnection i get another error : The solution is: undefined events.js:141 throw er; // Unhandled 'error' event ^ Error: read ECONNRESET at exports._errnoException (util.js:873:11) at TLSWrap.onread (net.js:557:26) – Ruslan Safarov May 28 '17 at 20:57
  • Anyway thanks for an answer :) I guess I am missing something, I will accept answer. – Ruslan Safarov May 28 '17 at 20:58