17

I'm currently using this connection URL for MYSQL

mysql://root:macbookair@localhost:3306/test_db

and getting this error.

[INFO] require: ./mysql
[INFO] connecting
[ERROR] Error: ER_ACCESS_DENIED_ERROR: Access denied for user 'root'@'localhost' (using password: YES)

How do I specify the password in the MYSQL connection URL?

Mawuli Adzoe
  • 849
  • 1
  • 6
  • 9

3 Answers3

54

Got it now.

The connection URL is in this format:

mysql://<username>:<password>@<host>:<port>/<db_name>

thus the password worked when I replaced macbookair in my url with the password.

Mawuli Adzoe
  • 849
  • 1
  • 6
  • 9
  • 6
    what if the password contains @ ?? – Akarsh Jain Nov 04 '19 at 15:52
  • 7
    replace @ it with %40 in password string – ajoy sinha Jan 13 '20 at 07:53
  • What if your password contains `%40`? Is there some encoding scheme standard for all forms of connecting to MySQL via connect string? Are they always URL-encoded? – bsplosion Dec 06 '22 at 06:17
  • %2540 as the encoding for % is %25 @bsplosion – Cai Allin Dec 07 '22 at 11:11
  • Interesting - it looks like only `: / ? # [ ] @` characters have to be escaped, at least based on [MongoDB's documentation](https://www.mongodb.com/docs/manual/reference/connection-string/#components). It seems like it's functionally the same treatment as required for escaping URL query param values. – bsplosion Dec 07 '22 at 14:09
15

try below

jdbc:mysql://localhost:3306/organizer?user=root&password=root
Pravin Bansal
  • 4,315
  • 1
  • 28
  • 19
-2

Try this:

Standard

Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword;

Specifying TCP port

Server=myServerAddress;Port=1234;Database=myDataBase;Uid=myUsername;
Pwd=myPassword;