• 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

strange problem when accessing MySQL

 
Ranch Hand
Posts: 3852
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I am getting a problem with MySQL, which I am not able to figure out, Why.

When I access MySQL with it's command line client, it asks me just password which I give 'admin' and it works (I might have given this at the time of installation).

But when I go into [MySql Home]\bin directory through command prompt and run following command:

mysql -h localhost -u admin -p admin

It asks me password (why again?), and when I give 'admin', it gives following error:

ERROR 1045 (28000): Access denied for user 'admin'@'localhost' (using password: YES)

Note: I am not sure if I gave 'admin' as username while installation.

What can be the problem?

Thanks.
[ January 22, 2008: Message edited by: ankur rathi ]
 
ankur rathi
Ranch Hand
Posts: 3852
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As I guessed, the username and password combination was not correct. So I changed the command:

mysql -h localhost -u root -p admin

Now it gives following error:

ERROR 1049 (42000): Unknown database 'admin'

I have no clue, what is this error? How to solve?
 
ankur rathi
Ranch Hand
Posts: 3852
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Now I run this command:

mysql -u root -p mysql

It asks password, which I give 'admin' and it works.
 
ankur rathi
Ranch Hand
Posts: 3852
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
But I am confused. Why is it asking password again?
 
ankur rathi
Ranch Hand
Posts: 3852
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Now when I run following program using JDBC API:



It gives this exception:

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

No idea, what all is happening? I should go home now.
 
Marshal
Posts: 79178
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why is it asking for the password? Because it interprets the -p tag as meaning a password will follow.
 
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Problem is at your end.
I got correct results for the queries that you mentioned.

Pankaj Shinde
SCJP
 
ankur rathi
Ranch Hand
Posts: 3852
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Campbell Ritchie:
Why is it asking for the password? Because it interprets the -p tag as meaning a password will follow.



That's what my one of the questions.
 
ankur rathi
Ranch Hand
Posts: 3852
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Pankaja Shinde:
Problem is at your end.

Pankaj Shinde
SCJP



But exactly where?
 
ankur rathi
Ranch Hand
Posts: 3852
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Guys, I solved the problem.

1. First I connected with 'root' user through command prompt:

mysql -u root -p mysql

It asks for password which I gave 'admin'.

Now I am logged in.

2. Then, I created another user with all privilege:

GRANT ALL PRIVILEGES ON *.* TO 'ankur'@'localhost' IDENTIFIED BY 'secret' WITH GRANT OPTION;

It creates user 'ankur' (password 'secret') which has all the permission.

Now the program:



And it worked.
 
Ranch Hand
Posts: 3389
Mac MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Great Ankur! Congrats :thumb:

I had also faced these issues and resolved through google search and Mysql Documentation.

Ultimately the grant option worked
 
The harder you work, the luckier you get. This tiny ad brings luck - just not good luck or bad luck.
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic