MySQL Tutorial/Privilege/User — различия между версиями

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

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

Add a user

mysql>
INSERT INTO user VALUES("localhost","TestUser",PASSWORD("pass123"),"Y","Y","Y","Y","Y","Y","Y","Y","Y","Y","Y","Y","Y","Y")
mysql>
mysql>


Add your database and users to the mysql database.

mysql>
INSERT INTO db VALUES("localhost","sample_db","TestUser","Y","Y","Y","Y","Y","Y","Y","Y","Y", "Y")
mysql>


In the default setting of MySQL access privileges, every user is permitted to create databases on a local computer that begin with the word "test."

To set up the new database test_sqle, in mysql execute the command CREATE DATABASE.



mysql> CREATE DATABASE test_sqle;


select convert(SUBSTR(USER(),1,INSTR(USER(),"@")-1) using latin1)

mysql>
mysql> select convert(SUBSTR(USER(),1,INSTR(USER(),"@")-1) using latin1) ;
+------------------------------------------------------------+
| convert(SUBSTR(USER(),1,INSTR(USER(),"@")-1) using latin1) |
+------------------------------------------------------------+
| root                                                       |
+------------------------------------------------------------+
1 row in set (0.09 sec)
mysql>


SELECT host, user, select_priv, update_priv FROM user

mysql> use mysql
Database changed
mysql> SELECT host, user, select_priv, update_priv FROM user;
+------------+------+-------------+-------------+
| host       | user | select_priv | update_priv |
+------------+------+-------------+-------------+
| localhost  | root | Y           | Y           |
| production | root | Y           | Y           |
| 127.0.0.1  | root | Y           | Y           |
+------------+------+-------------+-------------+
3 rows in set (0.03 sec)
mysql>