MySQL Tutorial/Privilege/User

Материал из SQL эксперт
Версия от 09:49, 26 мая 2010; Admin (обсуждение | вклад) (1 версия)
(разн.) ← Предыдущая | Текущая версия (разн.) | Следующая → (разн.)
Перейти к: навигация, поиск

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>