2014-05-05 4:17 GMT+02:00 EdwardKing <zhan...@neusoft.com>:

> I use mysql to create a database and grant rights to a user
> hadooptest,then I use hadooptest to login mysql and use the database,but it
> failed. Why raise error after I grant rights? How to solve it? Thanks.
>
> My operation is follows:
>
> [hadoop@master ~]$ mysql -h localhost -u root -p
> Enter password:
> Welcome to the MySQL monitor.  Commands end with ; or \g.
> Your MySQL connection id is 3
> Server version: 5.5.37-log MySQL Community Server (GPL)
>
> Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights
> reserved.
>
> Oracle is a registered trademark of Oracle Corporation and/or its
> affiliates. Other names may be trademarks of their respective
> owners.
>
> Type 'help;' or '\h' for help. Type '\c' to clear the current input
> statement.
>
> mysql> create database hadooptest;
> mysql> grant all on hadooptest.* to 'hadoopuser'@'%' identified by
> '123456';
> Query OK, 0 rows affected (0.00 sec)
>
> mysql> flush priviledges;
> ERROR 1064 (42000): You have an error in your SQL syntax; check the manual
> that corresponds to your MySQL server version for the right syntax to use
> near 'priviledges' at line 1
> mysql> flush privileges;
> Query OK, 0 rows affected (0.00 sec)
>
> mysql> quit;
> Bye
>
> Then I use hadoopuser  with password 123456
> [hadoop@master ~]$ mysql -u hadoopuser -p
> Enter password:
> ERROR 1045 (28000): Access denied for user 'hadoopuser'@'localhost'
> (using password: YES)
>


Hello,

I assume MySQL is listening in 3306 so:
Try this:  mysql -u hadoopuser -plocalhost (or 127.0.0.1)

"%" doesn't match localhost so if you don't specify it you will be
attempting to connect via Unix Socket.
If you don't want to specify -hlocalhost all the time, just do the grant
with "@localhost" instead of "@%"

Hope this helps
Manuel.

Reply via email to