For testing/debug purposes I recently set my root mysql password to root
.
And I can access my mysql server from the command line like so:
$ mysql -uroot -proot
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 24
Server version: 8.0.12 Homebrew
Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
To be sure, I get access denied if I try to use an empty password
$ mysql -uroot
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
OK, so the password is now root right?
Well, I'm trying to use the mysql
package (Node) and they provide a simple test file. When I use it like so I get access denied:
### FILE `test.js`
var mysql = require('mysql');
var connection = mysql.createConnection({
host : 'localhost',
user : 'root',
password : 'root',
});
connection.connect();
connection.query('SELECT 1 + 1 AS solution', function (error, results, fields) {
if (error) throw error;
console.log('The solution is: ', results[0].solution);
});
connection.end();
### end of `test.js`
$ node test.js
ER_ACCESS_DENIED_ERROR: Access denied for user 'root'@'localhost' (using password: YES)
The reason I'm posting this is that if I just change the password above to an empty string I get the expected output:
$ node test.js
The solution is: 2
How can this be?
Details:
- mysql Ver 8.0.12 for osx10.13 on x86_64 (Homebrew)
- Node v9.10.1
- mysql package version: 2.16