Отправлено Ноя 1, 2012

Метки: ,

mysql read only user

Если вдруг кто забыл, как сделать пользователя только для чтения, вот вам напоминалка:

>mysql -u root -pretneciyf
 
mysql> USE fyi;
Database changed
 
mysql> CREATE TABLE links (id INTEGER, name VARCHAR(80));
Query OK, 0 rows affected (0.14 sec)
 
mysql> INSERT INTO links VALUES (1, 'dba.fyicenter.com');
Query OK, 1 row affected (0.05 sec)
 
mysql> CREATE USER guest IDENTIFIED BY 'pub';
Query OK, 0 rows affected (0.24 sec)
 
mysql> GRANT SELECT ON fyi.* TO guest;
Query OK, 0 rows affected (0.00 sec)
 
mysql> QUIT;
 
>mysql -u guest -ppub
 
mysql> use fyi;
Database changed
 
mysql> SELECT * FROM links;
+------+-------------------+
| id   | name              |
+------+-------------------+
|    1 | dba.fyicenter.com |
+------+-------------------+
1 row in set (0.04 sec)
 
mysql> INSERT INTO links VALUES (2, 'dev.fyicenter.com');
ERROR 1142 (42000): INSERT command denied to user 
 'guest'@'localhost' for table 'links'