I'm using Node and MySQL2
import mysql2 from 'mysql2'
Following successfully creates connection:
const connection = mysql2.createConnection({
host: 'localhost',
user: 'root',
password: 'My@Password',
database: 'MyDB',
})
But using the URI format with same attributes throws Access denied for user 'root'@'localhost' (using password: YES)
const connection = mysql2.createConnection(
'mysql://root:My@Password@localhost:3306/MyDB'
)
What is the mistake with URI format?
[UPDATE] I've tried to encode the @, but it still doesn't works
'mysql://root:My%40Password@localhost:3306/MyDB'
Is there a method in MySQL library that returns the URI? I can create successful connection using the first approach and see what URI it actually generates.