SQL/MySQL/User Permission/User Create — различия между версиями

Материал из SQL эксперт
Перейти к: навигация, поиск
м (1 версия)
 
м (1 версия)
 
(нет различий)

Текущая версия на 13:17, 26 мая 2010

Create a user named joe on localhost with a password of joe33

   <source lang="sql">

/* mysql> GRANT ALL ON databaseName.sales TO joe@localhost IDENTIFIED BY "joe33"; Query OK, 0 rows affected (0.08 sec) mysql> REVOKE DELETE, DROP, ALTER ON databaseName.sales FROM joe@localhost; Query OK, 0 rows affected (0.00 sec) mysql> SHOW GRANTS FOR joe@localhost; +--------------------------------------+ | Grants for joe@localhost | +--------------------------------------+ | GRANT ALL PRIVILEGES ON *.* TO "joe"@"localhost" IDENTIFIED BY PASSWORD "*97F8 429BFFF8381BDD2BBA8733F8AC7561051548" | | GRANT SELECT ON `databasename`.* TO "joe"@"localhost" WITH GRANT OPTION

                                     |

| GRANT SELECT, INSERT, UPDATE, CREATE, REFERENCES, INDEX ON `databasename`.`sal es" TO "joe"@"localhost" | +--------------------------------------+ 3 rows in set (0.01 sec)

  • /

/*

  Create a user named joe on localhost with a password of joe33, who has 
  ALL privileges on the sales table, and then revoke the DELETE, DROP, and 
  ALTER privileges.
  • /

GRANT ALL ON databaseName.sales TO joe@localhost IDENTIFIED BY "joe33"; REVOKE DELETE, DROP, ALTER ON databaseName.sales FROM joe@localhost; SHOW GRANTS FOR joe@localhost;


      </source>
   
  


Create User

   <source lang="sql">

/* mysql> /* mysql> Create a user named Joe with the password Joe552 and mysql> grant all privileges when logging in from any host. mysql> */ mysql> GRANT ALL ON *.* TO Joe@"%" IDENTIFIED BY "Joe552"; Query OK, 0 rows affected (0.00 sec) mysql> /* Verify the grant. */ mysql> SHOW GRANTS FOR Joe@"%"; +------------------------------------------------------------+ | Grants for Joe@%

                             |

+------------------------------------------------------------+ | GRANT ALL PRIVILEGES ON *.* TO "Joe"@"%" IDENTIFIED BY PASSWORD "*F321704F1412 6CFD84206702826EAF46D265E927" | +------------------------------------------------------------+ 1 row in set (0.00 sec)

  • /

/* Create a user named Joe with the password Joe552 and grant all privileges when logging in from any host.

  • /

GRANT ALL ON *.* TO Joe@"%" IDENTIFIED BY "Joe552"; /* Verify the grant. */ SHOW GRANTS FOR Joe@"%";

      </source>