Thomas Darimont
Erfahrenes Mitglied
Hallo,
Hier mal eine Anleitung fuer zum Einrichten eines read-only Users fuer MySQL:
Als root Absetzen:
Demo:
Gruss Tom
Hier mal eine Anleitung fuer zum Einrichten eines read-only Users fuer MySQL:
Als root Absetzen:
SQL:
GRANT SELECT ON test.* TO 'readonly'@'10.20.0.48' IDENTIFIED BY 'readonlypasswd';
Demo:
SQL:
C:\Documents and Settings\daritho>mysql -h localhost -P 33306 -u readonly -p -D test -v
Enter password: ******
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8 to server version: 4.1.11
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> use test;
Database changed
mysql> select * from foo;
--------------
select * from foo
--------------
Empty set (0.00 sec)
mysql> select * from foo;
--------------
select * from foo
--------------
+------+------------+
| id | data |
+------+------------+
| 1 | Hallo Welt |
+------+------------+
1 row in set (0.00 sec)
mysql> select current_user();
--------------
select current_user()
--------------
+---------------------+
| current_user() |
+---------------------+
| readonly@10.20.0.48 |
+---------------------+
1 row in set (0.00 sec)
mysql> insert into foo values (2,'hacker');
--------------
insert into foo values (2,'hacker')
--------------
ERROR 1044 (42000): Access denied for user 'readonly'@'10.20.0.48' to database 'test'
mysql> update foo set data = 'hacker' where id = 1;
--------------
update foo set data = 'hacker' where id = 1
--------------
ERROR 1044 (42000): Access denied for user 'readonly'@'10.20.0.48' to database 'test'
mysql> delete from foo;
--------------
delete from foo
--------------
ERROR 1044 (42000): Access denied for user 'readonly'@'10.20.0.48' to database 'test'
mysql>
Gruss Tom