Mysql an Grafana: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
(Die Seite wurde neu angelegt: „=Datenbank anlegen= *mysql -u root -p =In Mysql= ==Datenbankl anlegen== *create database covid19; ==Tabellen anlegen== *use covid19; *create table statistik (d…“) |
|||
| (5 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt) | |||
| Zeile 3: | Zeile 3: | ||
=In Mysql= | =In Mysql= | ||
==Datenbankl anlegen== | ==Datenbankl anlegen== | ||
| − | *create database covid19; | + | **create database covid19; |
==Tabellen anlegen== | ==Tabellen anlegen== | ||
*use covid19; | *use covid19; | ||
| − | *create table | + | *create table statistics (datum date, best_faelle int, genesene int, verstorbene int); |
| + | |||
=User anlegen und Rechte geben= | =User anlegen und Rechte geben= | ||
*create user 'covid-admin'@'localhost' identified by 'oimel'; | *create user 'covid-admin'@'localhost' identified by 'oimel'; | ||
*grant all privileges on covid19.* to 'covid-admin'@'localhost'; | *grant all privileges on covid19.* to 'covid-admin'@'localhost'; | ||
*flush privileges; | *flush privileges; | ||
| + | =Tabelle anzeigen= | ||
| + | *desc statistik; | ||
| + | <pre> | ||
| + | +-------------+---------+------+-----+---------+-------+ | ||
| + | | Field | Type | Null | Key | Default | Extra | | ||
| + | +-------------+---------+------+-----+---------+-------+ | ||
| + | | datum | date | YES | | NULL | | | ||
| + | | best_faelle | int(11) | YES | | NULL | | | ||
| + | | genesens | int(11) | YES | | NULL | | | ||
| + | | verstorbene | int(11) | YES | | NULL | | | ||
| + | +-------------+---------+------+-----+---------+-------+ | ||
| + | 4 rows in set (0.00 sec) | ||
| + | </pre> | ||
| + | =CSV Datei importieren= | ||
| + | *load data local infile '/root/rki.csv' into table statistics fields terminated by ','; | ||
| + | *select * from statistics; | ||
| + | <pre> | ||
| + | +------------+-------------+----------+-------------+ | ||
| + | | datum | best_faelle | genesene | verstorbene | | ||
| + | +------------+-------------+----------+-------------+ | ||
| + | | 2020-03-04 | 262 | 0 | 0 | | ||
| + | | 2020-03-05 | 400 | 0 | 0 | | ||
| + | | 2020-03-06 | 639 | 0 | 0 | | ||
| + | | 2020-03-07 | 795 | 0 | 0 | | ||
| + | | 2020-03-08 | 902 | 0 | 0 | | ||
| + | ... | ||
| + | ... | ||
| + | ... | ||
| + | </pre> | ||
| + | =Grafana= | ||
| + | *Configuration | ||
| + | **Data Sources | ||
| + | ***New Data Source | ||
| + | ****Mysql | ||
| + | =Hinzufügen= | ||
| + | |||
| + | [[Datei:mysql-grafana-1.png|500px]] | ||
Aktuelle Version vom 19. Juni 2020, 09:25 Uhr
Datenbank anlegen
- mysql -u root -p
In Mysql
Datenbankl anlegen
- create database covid19;
Tabellen anlegen
- use covid19;
- create table statistics (datum date, best_faelle int, genesene int, verstorbene int);
User anlegen und Rechte geben
- create user 'covid-admin'@'localhost' identified by 'oimel';
- grant all privileges on covid19.* to 'covid-admin'@'localhost';
- flush privileges;
Tabelle anzeigen
- desc statistik;
+-------------+---------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-------------+---------+------+-----+---------+-------+ | datum | date | YES | | NULL | | | best_faelle | int(11) | YES | | NULL | | | genesens | int(11) | YES | | NULL | | | verstorbene | int(11) | YES | | NULL | | +-------------+---------+------+-----+---------+-------+ 4 rows in set (0.00 sec)
CSV Datei importieren
- load data local infile '/root/rki.csv' into table statistics fields terminated by ',';
- select * from statistics;
+------------+-------------+----------+-------------+ | datum | best_faelle | genesene | verstorbene | +------------+-------------+----------+-------------+ | 2020-03-04 | 262 | 0 | 0 | | 2020-03-05 | 400 | 0 | 0 | | 2020-03-06 | 639 | 0 | 0 | | 2020-03-07 | 795 | 0 | 0 | | 2020-03-08 | 902 | 0 | 0 | ... ... ...
Grafana
- Configuration
- Data Sources
- New Data Source
- Mysql
- New Data Source
- Data Sources