List:MySQL and Java« Previous MessageNext Message »
From:raffi@dcit.com Date:January 8 2003 5:21pm
Subject:The problem gets deeper still
View as plain text  
Unfortunetly, creating the dwarves database first doesnt change the 
outcome. Also, the problem is deeper. If you do what the code says just 
using the mysql client, you get the same problem. Its not just a java thing.

In other words... install a fresh mysql 4 and do this....
mysql -u root
mysql> create database dwarves;
mysql> grant all privileges on *.* to doc identified by 'doc' with grant 
option;
mysql> grant all privileges on *.* to doc@localhost identified by 'doc' 
with grant option;
mysql> exit

mysql -u doc -pdoc mysql
mysql> grant all privileges on dwarves.* to dopey identified by 'dopey';
Access denied for user: 'doc@stripped' to database 'dwarves'



Here is what the mysql.user and mysql.db tables look like after the code 
is run...



+-----------+------+------------------+-------------+-------------+-------------+
| Host      | User | Password         | Select_priv | Insert_priv | 
Update_priv | Delete_priv | Create_priv | Drop_priv | Reload_priv | 
Shutdown_priv | Process_priv | File_priv | Grant_priv | References_priv 
| Index_priv | Alter_priv |
+-----------+------+------------------+-------------+-------------+-------------+ 
| Y           | Y           | Y         | Y           | Y             | 
Y            | Y         | Y          | Y               | Y          | Y 
          |
| %         | root |                  | Y           | Y           | Y 
         | Y           | Y           | Y         | Y           | Y 
        | Y            | Y         | Y          | Y               | Y 
        | Y          |
| localhost |      |                  | Y           | Y           | Y 
         | Y           | Y           | Y         | Y           | Y 
        | Y            | Y         | Y          | Y               | Y 
        | Y          |
| %         |      |                  | N           | N           | N 
         | N           | N           | N         | N           | N 
        | N            | N         | N          | N               | N 
        | N          |
| %         | doc  | 7b135fb822ad6e43 | Y           | Y           | Y 
         | Y           | Y           | Y         | Y           | Y 
        | Y            | Y         | Y          | Y               | Y 
        | Y          |
| localhost | doc  | 7b135fb822ad6e43 | Y           | Y           | Y 
         | Y           | Y           | Y         | Y           | Y 
        | Y            | Y         | Y          | Y               | Y 
        | Y          |
+-----------+------+------------------+-------------+-------------+-------------+
6 rows in set (0.00 sec)





+------+-------+------+-------------+-------------+-------------+-------------+
| Host | Db    | User | Select_priv | Insert_priv | Update_priv | 
Delete_priv | Create_priv | Drop_priv | Grant_priv | References_priv | 
Index_priv | Alter_priv |
+------+-------+------+-------------+-------------+-------------+-------------+
| %    | test% |      | Y           | Y           | Y           | Y 
       | Y           | Y         | N          | Y               | Y 
      | Y          |
+------+-------+------+-------------+-------------+-------------+-------------+
1 row in set (0.01 sec)










mike markovich wrote:
> Hi,
> 
> I ran your code on my box with MySQL 3.23 and it runs fine.  Just
> curious, but what happens if you create the "dwarves" database before
> you grant access to "doc".  If this works then something has probably
> changed with granting super user access in MySQL 4.0.  Please let me
> know what you find out.
> 
> Mike
> 
> 
> -----Original Message----- From: raffi@stripped
> [mailto:raffi@stripped] Sent: Monday, January 06, 2003 1:10 PM To:
> java@stripped Subject: mysql 4 doesnt match ip address to %
> ???
> 
> 
> Hi all.
> 
> Does anyone know why the following code DOES NOT work on mysql
> 4.0.7-nt gamma and it DOES work on MySQL 3.23.whatever-nt.
> 
> Here is what you will get on MySQL 4... General error: Access denied
> for user: 'doc@stripped' to database 'dwarves'
> 
> I've tested on a brand new installation as well. Same problem.
> 
> Why??? Thanks.
> 
> 
> 
> --------- example code ------------
> 
>     public static void main(String[] args)
>     {
>         try
>         {
>             Class.forName("org.gjt.mm.mysql.Driver").newInstance();
>             Connection c =
> DriverManager.getConnection("jdbc:mysql://localhost/","root","");
>             System.out.println("connected to database as root");
>             Statement stat = c.createStatement();
>             stat.execute("create database dwarves");
>             stat.execute("GRANT ALL PRIVILEGES ON *.* TO doc IDENTIFIED BY 'doc' WITH
> GRANT OPTION");
>             stat.execute("GRANT ALL PRIVILEGES ON *.* TO doc@localhost IDENTIFIED BY
> 'doc' WITH GRANT OPTION");
>             c.close();
> 
>             Connection cc =
> DriverManager.getConnection("jdbc:mysql://localhost/","doc","doc");
>             System.out.println("connected to database as doc");
>             stat = cc.createStatement();
>             stat.execute("GRANT All PRIVILEGES ON dwarves.* TO dopey IDENTIFIED BY
> 'dopey'");
>             stat.execute("GRANT All PRIVILEGES ON dwarves.* TO dopey@localhost
> IDENTIFIED BY 'dopey'");
>             c.close();
>         } catch (Exception e) {
>             System.out.println(e.getMessage());
>         }
>     }



-- 
Raffi Minassian
DCIT Corporation
http://www.dcit.com
============================================================
** Nothing is so embarrassing as watching someone do
something that you said couldn't be done. **
============================================================

Thread
The problem gets deeper stillraffi@dcit.com8 Jan
  • Re: The problem gets deeper stillMark Matthews8 Jan
RE: The problem gets deeper stillmike markovich8 Jan
  • Re: The problem gets deeper stillraffi@dcit.com10 Jan