tags:

views:

12

answers:

2

Hello!

My problem is: I had created a new user:GRANT ALL PRIVILAGES ON sampdb.* TO 'monty'@'' IDENTIFIED BY 'pass' This user had appiared in two databases: mysql.user(with no privilages at all) and mysql.db(with nearly all privilages except GRANT one). OK. After that I tried to access the sampdb database by this new user:mysql -u monty -ppass sampdb. MySQL answered: "Access denied for user 'monty'@'localhost (using password: YES)'.

Please, tell me, where did I mistake?

+2  A: 

I think you need to grant the privileges to 'monty'@'localhost', rather than 'monty'@''. At the moment, you're trying to connect via localhost, and 'monty'@'localhost' doesn't exist.

edit: Or 'monty'@'%', to allow connections from any host.

Hammerite
+1, or `'monty'@'%'` for all hosts, or a specific other host, as the need may be.
Wrikken
You must have a user with all privileges already in order to be running the GRANT command you quoted, so log in as that user and issue `SHOW GRANTS FOR 'monty'@''` and `SHOW GRANTS FOR 'monty'@'localhost'` and see what is output.
Hammerite
Yes!!! I don't know why nothing changed for the first time, but now it works!!!
Dmitry
A: 

As you said I have added 'monty'@'%'. Now I have granted an access!!! But something wrong with the configuration file. I have added to it: [client] port=3306 user=monty password=pass

And after a command: mysql sampdb the anwer "access dinied" is received... What's wrong?
Also:

Grants for  monty@localhost                                                                        
GRANT USAGE ON *.* TO 'monty'@'localhost' IDENTIFIED BY PASSWORD*196BDEDE2AE4F84CA44C47D54D78478C7E2BD7B7' 
GRANT ALL PRIVILEGES ON `sampdb`.* TO monty'@'localhost'                                                   
Dmitry
It is strange that after having changed the my.ini(modifing [client] group), the user root has no access too!!!! What's happened???
Dmitry