Skip to content

Commit 4fc8195

Browse files
Update instructions for mysql user grants (#4552)
Update instructions for mysql user grants Updated instructions for granting user privileges in mysql Followup of #4528
1 parent e02c900 commit 4fc8195

File tree

1 file changed

+17
-12
lines changed
  • internal/component/database_observability

1 file changed

+17
-12
lines changed

internal/component/database_observability/README.md

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,24 @@
1313
```sql
1414
CREATE USER 'db-o11y'@'%' IDENTIFIED by '<password>';
1515
GRANT PROCESS, REPLICATION CLIENT ON *.* TO 'db-o11y'@'%';
16-
GRANT SELECT, SHOW VIEW ON *.* TO 'db-o11y'@'%'; /* see note */
16+
GRANT SELECT ON performance_schema.* TO 'db-o11y'@'%';
1717
```
1818

19-
Please note: Regarding `GRANT SELECT, SHOW VIEW ON *.* TO 'db-o11y'@'%'`, it is possible to restrict permissions, if necessary. Instead, grant the `db-o11y` user privileges access only to the objects (schemas) for which you want information. For example, to restrict permissions only to a schema named `payments`:
19+
3. Grant the `db-o11y` user additional privileges to access the objects (schemas, tables, views) for which you want to collect detailed information.
20+
21+
For example, to limit permissions only to a schema named `payments`:
2022

2123
```sql
22-
CREATE USER 'db-o11y'@'%' IDENTIFIED by '<password>';
23-
GRANT PROCESS, REPLICATION CLIENT ON *.* TO 'db-o11y'@'%';
24-
GRANT SELECT ON performance_schema.* TO 'db-o11y'@'%'; /* required */
25-
GRANT SELECT, SHOW VIEW ON payments.* TO 'db-o11y'@'%'; /* limit grant to the `payments` schema */
24+
GRANT SELECT, SHOW VIEW ON payments.* TO 'db-o11y'@'%';
25+
```
26+
27+
Alternatively, grant access to all available schemas:
28+
29+
```sql
30+
GRANT SELECT, SHOW VIEW ON *.* TO 'db-o11y'@'%';
2631
```
2732

28-
3. Verify that the user has been properly created.
33+
4. Verify that the user has been properly created.
2934

3035
```sql
3136
SHOW GRANTS FOR 'db-o11y'@'%';
@@ -38,7 +43,7 @@ SHOW GRANTS FOR 'db-o11y'@'%';
3843
+-------------------------------------------------------------------+
3944
```
4045

41-
4. Enable Performance Schema. To enable it explicitly, start the server with the `performance_schema` variable set to an appropriate value. Verify that Performance Schema has been enabled:
46+
5. Enable Performance Schema. To enable it explicitly, start the server with the `performance_schema` variable set to an appropriate value. Verify that Performance Schema has been enabled:
4247

4348
```sql
4449
SHOW VARIABLES LIKE 'performance_schema';
@@ -50,7 +55,7 @@ SHOW VARIABLES LIKE 'performance_schema';
5055
+--------------------+-------+
5156
```
5257

53-
5. Increase `max_digest_length` and `performance_schema_max_digest_length` to `4096`. Verify that the changes have been applied:
58+
6. Increase `max_digest_length` and `performance_schema_max_digest_length` to `4096`. Verify that the changes have been applied:
5459

5560
```sql
5661
SHOW VARIABLES LIKE 'max_digest_length';
@@ -74,7 +79,7 @@ SHOW VARIABLES LIKE 'performance_schema_max_digest_length';
7479
+--------------------------------------+-------+
7580
```
7681

77-
6. [OPTIONAL] Increase `performance_schema_max_sql_text_length` to `4096` if you want to collect the actual, unredacted sql text from queries samples (this requires setting `disable_query_redaction` to `true`, see later). Verify that the changes have been applied:
82+
7. [OPTIONAL] Increase `performance_schema_max_sql_text_length` to `4096` if you want to collect the actual, unredacted sql text from queries samples (this requires setting `disable_query_redaction` to `true`, see later). Verify that the changes have been applied:
7883

7984
```sql
8085
SHOW VARIABLES LIKE 'performance_schema_max_sql_text_length';
@@ -86,7 +91,7 @@ SHOW VARIABLES LIKE 'performance_schema_max_sql_text_length';
8691
+----------------------------------------+-------+
8792
```
8893

89-
7. [OPTIONAL] Enable the `events_statements_cpu` consumer if you want to capture CPU activity and time on query samples. Verify the current setting with a sql query:
94+
8. [OPTIONAL] Enable the `events_statements_cpu` consumer if you want to capture CPU activity and time on query samples. Verify the current setting with a sql query:
9095

9196
```sql
9297
SELECT * FROM performance_schema.setup_consumers WHERE NAME = 'events_statements_cpu';
@@ -121,7 +126,7 @@ database_observability.mysql "mysql_<your_DB_name>" {
121126
}
122127
```
123128

124-
8. [OPTIONAL] Enable the `events_waits_current` and `events_waits_history` consumers if you want to collect wait events for each query sample. Verify the current settings with a sql query:
129+
9. [OPTIONAL] Enable the `events_waits_current` and `events_waits_history` consumers if you want to collect wait events for each query sample. Verify the current settings with a sql query:
125130

126131
```sql
127132
SELECT * FROM performance_schema.setup_consumers WHERE NAME IN ('events_waits_current', 'events_waits_history');

0 commit comments

Comments
 (0)