• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

mySQl/JDBC error

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Does anyone know why I would get this message when trying to connect to mySQL?


java.sql.SQLException: Access denied for user 'root'@'localhost' (using password : YES)

I have the latest drivers (jar files) and mysql has been configured such that localhost is granted all privileges.

Here is a code snippet:


[ September 17, 2006: Message edited by: William Joel ]

[ September 17, 2006: Message edited by: William Joel ]
[ September 17, 2006: Message edited by: William Joel ]
 
Ranch Hand
Posts: 518
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have you granted the root user access to mysql?

Take a look at the mysql manual for how to do this.

By the way, it's not a good practice to run any process as root or login to a database or other application as root. Root is a security risk so it's best to setup another, less privileged user account.
[ September 17, 2006: Message edited by: Scott Johnson ]
 
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You probably have mistyped the password as root is root or are trying to connect right after the install using a password and by default it is blank.

Sometime in jdbc urls, depending on how localhost resolves, it is better to use the numeric IP equivalent 127.0.0.1 instead of localhost.

The security concerns mentioned here are very much valid so create a user and a database connect on the command line/prompt and then try it in jdbc that way you will narrow down the problem.

Good luck.
George
 
reply
    Bookmark Topic Watch Topic
  • New Topic