Nach Neuinstallation aufgrund Upgrade Linux auf Bullseye light mysql Fehler

Begonnen von UweUwe, 18 November 2022, 22:43:13

Vorheriges Thema - Nächstes Thema

CoolTux

Deine Datenbank lauscht wohl auf 3306 wenn ich das richtig lese.

Du kannst auch verschieben. Ganz unten links müsste der Knopf dafür sein.
Du musst nicht wissen wie es geht! Du musst nur wissen wo es steht, wie es geht.
Support me to buy new test hardware for development: https://www.paypal.com/paypalme/MOldenburg
My FHEM Git: https://git.cooltux.net/FHEM/
Das TuxNet Wiki:
https://www.cooltux.net

UweUwe

Hallo Cooltux,

hab mal versucht den Port auf 3306 zu ändern. Hab dasselbe Thema:

could not read connection

wenn ich das device in FHEM spezifiziere mit:

define DBLogging DbLog /opt/fhem/db.conf .*:.*

Die geänderte Datei (Port 3306) lautet:
pi@Vagabundi02:~ $ pi@Vagabundi02:~ $ cat /opt/fhem/db.conf
O
####################################################################################
# database configuration file
#
# NOTE:
# If you don't use a value for user / password please delete the leading hash mark
# and write 'user => ""' respectively 'password => ""' instead !
#
#
## for MySQL
####################################################################################
#%dbconfig= (
    connection => "mysql:database=fhem;host=localhost;port=3306",
    user => "fhemuser",
    password => "Passwort",
    # optional enable(1) / disable(0) UTF-8 support (at least V 4.042 is necessary)
    utf8 => 1
);
####################################################################################
#
## for PostgreSQL
####################################################################################
#%dbconfig= (
#    connection => "Pg:database=fhem;host=localhost",
#    user => "fhemuser",
#    password => "fhempassword"
#);
####################################################################################
#
## for SQLite (username and password stay empty for SQLite)
####################################################################################
#%dbconfig= (
#    connection => "SQLite:dbname=/opt/fhem/fhem.db",
#    user => "",
#    password => ""
#);
####################################################################################
pi@Vagabundi02:~ $







CoolTux

Bitte schau einmal was in der /etc/mysql/my.cnf drin steht. Da sollte ja auch der Port stehen. Per default ist es immer 3306

Dann musst Du eine bind-adresse angeben

bind-address = 0.0.0.0

für remote Zugriff aus allen Netzen.

testen dann mit

mysql -u root -p -h 127.0.0.1 -P 3306

direkt auf dem FHEM Server
Du musst nicht wissen wie es geht! Du musst nur wissen wo es steht, wie es geht.
Support me to buy new test hardware for development: https://www.paypal.com/paypalme/MOldenburg
My FHEM Git: https://git.cooltux.net/FHEM/
Das TuxNet Wiki:
https://www.cooltux.net

UweUwe

Hallo Cooltux,

das geht mir zu schnell, sorry.

Ich will mal darstellen, was ich verstanden habe:

Die bind adress finde ich nur in dieser Konfigurationsdatei:

pi@Vagabundi02:~ $ cat /etc/mysql/mariadb.conf.d/50-server.cnf
#
# These groups are read by MariaDB server.
# Use it for options that only the server (but not clients) should see
#
# See the examples of server my.cnf files in /usr/share/mysql/
#

# this is read by the standalone daemon and embedded servers
[server]

# this is only for the mysqld standalone daemon
[mysqld]

#
# * Basic Settings
#
user            = mysql
pid-file        = /var/run/mysqld/mysqld.pid
socket          = /var/run/mysqld/mysqld.sock
port            = 3306
basedir         = /usr
datadir         = /var/lib/mysql
tmpdir          = /tmp
lc-messages-dir = /usr/share/mysql
skip-external-locking

# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
# bind-address          = 127.0.0.1

#
# * Fine Tuning
#
key_buffer_size         = 16M
max_allowed_packet      = 16M
thread_stack            = 192K
thread_cache_size       = 8
# This replaces the startup script and checks MyISAM tables if needed
# the first time they are touched
myisam-recover         = BACKUP
#max_connections        = 100
#table_cache            = 64
#thread_concurrency     = 10

#
# * Query Cache Configuration
#
query_cache_limit       = 1M
query_cache_size        = 16M

#
# * Logging and Replication
#
# Both location gets rotated by the cronjob.
# Be aware that this log type is a performance killer.
# As of 5.1 you can enable the log at runtime!
#general_log_file        = /var/log/mysql/mysql.log
#general_log             = 1
#
# Error log - should be very few entries.
#
log_error = /var/log/mysql/error.log
#
# Enable the slow query log to see queries with especially long duration
#slow_query_log_file    = /var/log/mysql/mariadb-slow.log
#long_query_time = 10
#log_slow_rate_limit    = 1000
#log_slow_verbosity     = query_plan
#log-queries-not-using-indexes
#
# The following can be used as easy to replay backup logs or for replication.
# note: if you are setting up a replication slave, see README.Debian about
#       other settings you may need to change.
#server-id              = 1
#log_bin                        = /var/log/mysql/mysql-bin.log
expire_logs_days        = 10
max_binlog_size   = 100M
#binlog_do_db           = include_database_name
#binlog_ignore_db       = include_database_name

#
# * InnoDB
#
# InnoDB is enabled by default with a 10MB datafile in /var/lib/mysql/.
# Read the manual for more InnoDB related options. There are many!

#
# * Security Features
#
# Read the manual, too, if you want chroot!
# chroot = /var/lib/mysql/
#
# For generating SSL certificates you can use for example the GUI tool "tinyca".
#
# ssl-ca=/etc/mysql/cacert.pem
# ssl-cert=/etc/mysql/server-cert.pem
# ssl-key=/etc/mysql/server-key.pem
#
# Accept only connections using the latest and most secure TLS protocol version.
# ssl-cipher=TLSv1.2


#
# * Character sets
#
# MySQL/MariaDB default is Latin1, but in Debian we rather default to the full
# utf8 4-byte character set. See also client.cnf
#
character-set-server  = utf8mb4
collation-server      = utf8mb4_general_ci

#
# * Unix socket authentication plugin is built-in since 10.0.22-6
#
# Needed so the root database user can authenticate without a password but
# only when running as the unix root user.
#
# Also available for other users if required.
# See https://mariadb.com/kb/en/unix_socket-authentication-plugin/

# this is only for embedded server
[embedded]

# This group is only read by MariaDB servers, not by MySQL.
# If you use the same .cnf file for MySQL and MariaDB,
# you can put MariaDB-only options here
[mariadb]

# This group is only read by MariaDB-10.0 servers.
# If you use the same .cnf file for MariaDB of different versions,
# use this group for options that older servers don't understand
[mariadb-10.0]
pi@Vagabundi02:~ $ cat /etc/mysql/mariadb.conf.d/50-server.cnf
#
# These groups are read by MariaDB server.
# Use it for options that only the server (but not clients) should see
#
# See the examples of server my.cnf files in /usr/share/mysql/
#

# this is read by the standalone daemon and embedded servers
[server]

# this is only for the mysqld standalone daemon
[mysqld]

#
# * Basic Settings
#
user            = mysql
pid-file        = /var/run/mysqld/mysqld.pid
socket          = /var/run/mysqld/mysqld.sock
port            = 3306
basedir         = /usr
datadir         = /var/lib/mysql
tmpdir          = /tmp
lc-messages-dir = /usr/share/mysql
skip-external-locking

# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
# bind-address          = 127.0.0.1

#
# * Fine Tuning
#
key_buffer_size         = 16M
max_allowed_packet      = 16M
thread_stack            = 192K
thread_cache_size       = 8
# This replaces the startup script and checks MyISAM tables if needed
# the first time they are touched
myisam-recover         = BACKUP
#max_connections        = 100
#table_cache            = 64
#thread_concurrency     = 10

#
# * Query Cache Configuration
#
query_cache_limit       = 1M
query_cache_size        = 16M

#
# * Logging and Replication
#
# Both location gets rotated by the cronjob.
# Be aware that this log type is a performance killer.
# As of 5.1 you can enable the log at runtime!
#general_log_file        = /var/log/mysql/mysql.log
#general_log             = 1
#
# Error log - should be very few entries.
#
log_error = /var/log/mysql/error.log
#
# Enable the slow query log to see queries with especially long duration
#slow_query_log_file    = /var/log/mysql/mariadb-slow.log
#long_query_time = 10
#log_slow_rate_limit    = 1000
#log_slow_verbosity     = query_plan
#log-queries-not-using-indexes
#
# The following can be used as easy to replay backup logs or for replication.
# note: if you are setting up a replication slave, see README.Debian about
#       other settings you may need to change.
#server-id              = 1
#log_bin                        = /var/log/mysql/mysql-bin.log
expire_logs_days        = 10
max_binlog_size   = 100M
#binlog_do_db           = include_database_name
#binlog_ignore_db       = include_database_name

#
# * InnoDB
#
# InnoDB is enabled by default with a 10MB datafile in /var/lib/mysql/.
# Read the manual for more InnoDB related options. There are many!

#
# * Security Features
#
# Read the manual, too, if you want chroot!
# chroot = /var/lib/mysql/
#
# For generating SSL certificates you can use for example the GUI tool "tinyca".
#
# ssl-ca=/etc/mysql/cacert.pem
# ssl-cert=/etc/mysql/server-cert.pem
# ssl-key=/etc/mysql/server-key.pem
#
# Accept only connections using the latest and most secure TLS protocol version.
# ssl-cipher=TLSv1.2


#
# * Character sets
#
# MySQL/MariaDB default is Latin1, but in Debian we rather default to the full
# utf8 4-byte character set. See also client.cnf
#
character-set-server  = utf8mb4
collation-server      = utf8mb4_general_ci

#
# * Unix socket authentication plugin is built-in since 10.0.22-6
#
# Needed so the root database user can authenticate without a password but
# only when running as the unix root user.
#
# Also available for other users if required.
# See https://mariadb.com/kb/en/unix_socket-authentication-plugin/

# this is only for embedded server
[embedded]

# This group is only read by MariaDB servers, not by MySQL.
# If you use the same .cnf file for MySQL and MariaDB,
# you can put MariaDB-only options here
[mariadb]

# This group is only read by MariaDB-10.0 servers.
# If you use the same .cnf file for MariaDB of different versions,
# use this group for options that older servers don't understand
[mariadb-10.0]


Da bin ich angewiesen worden , die bind adress zu kommentieren.
Du sagst, ich mus hier

bind-address = 0.0.0.0

einfügen. Korrekt? Den Port auf 3306 belassen.

Was bedeutet "direkt auf dem FHEM Server?
Nicht aus FHEM, nehme ich an, sondern auf dem RPI.

wenn ich das Kommando jetzt  absetze (modifiziert auf "fhemuser" und ohne deine vorgeschlagene Änderung,  so bekomme ich :

pi@Vagabundi02:~ $ mysql -u fhemuser -p -h 127.0.0.1 -P 3306
Enter password:
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 695
Server version: 10.5.15-MariaDB-0+deb11u1 Raspbian 11

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]>


Wenn ich dein Kommando absetze, also mit root, so kenne ich das abgesetzte Passwort nicht.

pi@Vagabundi02:~ $ mysql -u root -p -h 127.0.0.1 -P 3306
Enter password:
ERROR 1698 (28000): Access denied for user 'root'@'localhost'



CoolTux

Ok das funktioniert also.
root war hier nur exemplarisch. Du hast also Zugriff über Netzwerk auf Deine mysql Datenbank.

nächster schritt

cat /opt/fhem/db.conf

hier hast Du ja


####################################################################################
# database configuration file
#
# NOTE:
# If you don't use a value for user / password please delete the leading hash mark
# and write 'user => ""' respectively 'password => ""' instead !
#
#
## for MySQL
####################################################################################
#%dbconfig= (                          <------------------------  Schau mal da steht ein # am Anfang das muss da weg
    connection => "mysql:database=fhem;host=localhost;port=3306",
    user => "fhemuser",
    password => "Passwort",
    # optional enable(1) / disable(0) UTF-8 support (at least V 4.042 is necessary)
    utf8 => 1
);
####################################################################################
#
## for PostgreSQL
####################################################################################
#%dbconfig= (
#    connection => "Pg:database=fhem;host=localhost",
#    user => "fhemuser",
#    password => "fhempassword"
#);
####################################################################################
#
## for SQLite (username and password stay empty for SQLite)
####################################################################################
#%dbconfig= (
#    connection => "SQLite:dbname=/opt/fhem/fhem.db",
#    user => "",
#    password => ""
#);
####################################################################################


Du bist Dir aber auch sicher das Du auf dem alten System mit configdb gearbeitet hast, ja?

Es scheint in der Konfig einen kleinen Fehler zu geben. Habe versucht das zu makieren
#%dbconfig= (
das # ist zu viel.

Wenn Du das richtig hast und fhem sagst das er mit configdb starten soll dann sollte er auch die config aus der configdb DB einlesen.
Du musst nicht wissen wie es geht! Du musst nur wissen wo es steht, wie es geht.
Support me to buy new test hardware for development: https://www.paypal.com/paypalme/MOldenburg
My FHEM Git: https://git.cooltux.net/FHEM/
Das TuxNet Wiki:
https://www.cooltux.net

betateilchen

Zitat von: CoolTux am 23 November 2022, 14:59:21
Du bist Dir aber auch sicher das Du auf dem alten System mit configdb gearbeitet hast, ja?

Es scheint in der Konfig einen kleinen Fehler zu geben. Habe versucht das zu makieren

Wenn Du das richtig hast und fhem sagst das er mit configdb starten soll dann sollte er auch die config aus der configdb DB einlesen.

Wenn vorher wirklich configDB im Einsatz war, ist es völlig wurscht, ob die genannten Zeile auskommentiert ist oder nicht.
Dann ist ausschließlich wichtig, was in /opt/fhem/configDB.conf als Verbindungsparameter steht.

Die Konfigurationsdatei für die Datenbank wird nämlich in dem Fall aus der configDB gelesen.

Das hatte bartman121 vor zwei Tagen schon hier im Thread geschrieben.
-----------------------
Formuliere die Aufgabe möglichst einfach und
setze die Lösung richtig um - dann wird es auch funktionieren.
-----------------------
Lesen gefährdet die Unwissenheit!

UweUwe

Hallo Cooltux,
danke für deine Antwort.

Ich hab jetzt das "Kommentarzeichen" entfernt. Toll , dass du es gesehen hast.
$ cat /opt/fhem/db.conf

####################################################################################
# database configuration file
#
# NOTE:
# If you don't use a value for user / password please delete the leading hash mark
# and write 'user => ""' respectively 'password => ""' instead !
#
#
## for MySQL
####################################################################################
%dbconfig= (
    connection => "mysql:database=fhem;host=localhost;port=3306",
    user => "fhemuser",
    password => "Passwort",
    # optional enable(1) / disable(0) UTF-8 support (at least V 4.042 is necessary)
    utf8 => 1
);
####################################################################################
#
## for PostgreSQL
####################################################################################
#%dbconfig= (
#    connection => "Pg:database=fhem;host=localhost",
#    user => "fhemuser",
#    password => "fhempassword"
#);
####################################################################################
#
## for SQLite (username and password stay empty for SQLite)
####################################################################################
#%dbconfig= (
#    connection => "SQLite:dbname=/opt/fhem/fhem.db",
#    user => "",
#    password => ""
#);
####################################################################################[/code]

In FHEM hab ich leider immer noch denselben Fehler

could not read connection

Ich habe deinen Hinweis mit der
bind-address = 0.0.0.0 noch nicht umgesetzt, weil ich nicht weiss, ob ich dies jetzt an der entsprechenden Stelle einsetzen soll oder nicht.
Kannst du mir bitte hier noch weitere Hinweise geben?

Vielen Dank

UweUwe

Hallo Betateilchen,

ZitatWenn vorher wirklich configDB im Einsatz war, ist es völlig wurscht, ob die genannten Zeile auskommentiert ist oder nicht.
Dann ist ausschließlich wichtig, was in /opt/fhem/configDB.conf als Verbindungsparameter steht.

Zur Erklärung: ich habe ein neues System auf Basis Bullseye hochgezogen und die neueste Version von FHEM benutzt.
Ich habe meinen Backup von FHEM verwendet.
In meinem alten System war die Definition der Datenbank so:

define DBLogging DbLog /opt/fhem/db.conf .*:.*

Ich habe noch nicht verstanden, was ich jetzt noch versuchen könnte?


betateilchen

Zitat von: UweUwe am 23 November 2022, 15:41:11
Ich habe deinen Hinweis mit der
bind-address = 0.0.0.0 noch nicht umgesetzt, weil ich nicht weiss, ob ich dies jetzt an der entsprechenden Stelle einsetzen soll oder nicht.
Kannst du mir bitte hier noch weitere Hinweise geben?

Mach doch einfach mal - schlimmer kann es ja nicht mehr werden.

Zitat von: UweUwe am 23 November 2022, 15:41:11
Ich hab jetzt das "Kommentarzeichen" entfernt. Toll , dass du es gesehen hast.
$ cat /opt/fhem/db.conf

Wenn hier wirklich auch noch configDB im Spiel ist, kannst Du die Datei auch auf Papier ausdrucken und an die Wand hängen, es wird nix nützen.

Zitat von: UweUwe am 23 November 2022, 15:41:11
In FHEM hab ich leider immer noch denselben Fehler

could not read connection

Diese Meldung wird nur ausgegeben, wenn das Konfigurationsfile für DbLog zwar gelesen werden kann, aber darin keine Verbindungsinformationen gefunden werden.
Zum Beispiel, weil Du zwar eine Datei bearbeitest, aber das gar nicht die Datei ist, die FHEM gerne lesen möchte.
Oder wenn die Verbindungsinformationen immer noch auskommentiert sind.

  return "could not read connection" if (!defined $dbconfig{connection});
-----------------------
Formuliere die Aufgabe möglichst einfach und
setze die Lösung richtig um - dann wird es auch funktionieren.
-----------------------
Lesen gefährdet die Unwissenheit!

betateilchen

Zitat von: UweUwe am 23 November 2022, 15:50:59
Ich habe noch nicht verstanden, was ich jetzt noch versuchen könnte?

Zum Beispiel endlich die Frage bezüglich configDB tatsächlich beantworten?
-----------------------
Formuliere die Aufgabe möglichst einfach und
setze die Lösung richtig um - dann wird es auch funktionieren.
-----------------------
Lesen gefährdet die Unwissenheit!

betateilchen

-----------------------
Formuliere die Aufgabe möglichst einfach und
setze die Lösung richtig um - dann wird es auch funktionieren.
-----------------------
Lesen gefährdet die Unwissenheit!

UweUwe

Hallo betateilchen:

Zum Beispiel endlich die Frage bezüglich configDB tatsächlich beantworten?

Ich habe mir vor 3 Jahren Notizen gemacht und die notwenigen Modifikationen von db.conf  so in meinen Notizen gefunden.

%dbconfig= (
    connection => "mysql:database=fhem;host=localhost;port=3306",
    user => "fhemuser",
    password => "aufReisen",
);


Ich vermute, dass dies deine Frage beantwortet. Ich kann nichts anderes sagen..

Wissen wir eigentlich schon, wie Du Dein FHEM startest?

FHEM startet bei mir, sobald der RPI hochfährt. Ich habe dazu kein eigenes Kommando.  Hab gerade nochmals ein shutdown restart gemacht von FHEM.
Das ändert auch nichts .






MadMax-FHEM

Zitat von: betateilchen am 23 November 2022, 15:59:00
Wissen wir eigentlich schon, wie Du Dein FHEM startest?

Das define was immer rumschwirrt ist doch für Logging in DB?

Zitat von: UweUwe"
define DBLogging DbLog /opt/fhem/db.conf .*:.*

https://wiki.fhem.de/wiki/DbLog#Konfiguration_als_Device

ConfigDB ist doch eine andere (evtl. zusätzliche?) Baustelle:
https://fhem.de/commandref.html#configDB

Und muss doch (auch) beim Starten angegeben werden?

(oder liege ich falsch?)

Gruß, Joachim
FHEM PI3B+ Bullseye: HM-CFG-USB, 40x HM, ZWave-USB, 13x ZWave, EnOcean-PI, 15x EnOcean, HUE/deCONZ, CO2, ESP-Multisensor, Shelly, alexa-fhem, ...
FHEM PI2 Buster: HM-CFG-USB, 25x HM, ZWave-USB, 4x ZWave, EnOcean-PI, 3x EnOcean, Shelly, ha-bridge, ...
FHEM PI3 Buster (Test)

betateilchen

Zitat von: MadMax-FHEM am 23 November 2022, 16:33:56
Das define was immer rumschwirrt ist doch für Logging in DB?

Natürlich. Und das funktioniert sogar. Die Konfigurationsdatei wird erfolgreich gelesen.

Aber WENN vorher configDB im Einsatz war und jetzt FHEM auch mit configDB startet, wird die Konfigurationsdatei für DbLog NICHT aus dem Filesystem gelesen, sondern aus der Datenbank. Deshalb ist es völlig wurscht, ob in der Datei im Filesystem irgendwas auskommentiert ist oder nicht - man könnte die Datei auch löschen.

Zitat von: UweUwe am 23 November 2022, 16:31:35
Ich vermute, dass dies deine Frage beantwortet.

Nein tut es nicht.

Zitat von: UweUwe am 23 November 2022, 16:31:35
Wissen wir eigentlich schon, wie Du Dein FHEM startest?

FHEM startet bei mir, sobald der RPI hochfährt. Ich habe dazu kein eigenes Kommando.

Mit solchen Antworten kommen wir auch in zwei Jahren nicht weiter.
-----------------------
Formuliere die Aufgabe möglichst einfach und
setze die Lösung richtig um - dann wird es auch funktionieren.
-----------------------
Lesen gefährdet die Unwissenheit!

UweUwe

Sorry Betateilchen,

ich kann nur gemäss meiner Wissensbasis antworten. Du kannst jetzt sagen, dass ich zu unwissend für FHEM bin, dann muss ich eindach aufhören.
Ich habe wirklich keine andere Chance. Ich tue mein Möglichstes.

Deinen Vorschlag :
bind-address = 0.0.0.0

hab ich umgesetzt, da bekomme ich dieselbe Fehlermeldung bei der Definition des devices in FHEM.
Ich hoffe auf weiteren Support.