Errorcode: 2003: Can't connect to MySQL server on 'localhost:3306' (111 Connection refused)

Hallo zusammen,

ich bin kompletter Anfänger was die Datenbank auf einen Rasberry Pi 4 betrifft.

Ich habe jetzt alles installiert und habe auch Zugriff über PHPmyAdmin. Dort kann ich alles machen, aber wenn ich mit meinem Programm eine Verbindung aufbauen will bekomme ich eine Fehlermeldung.

#!/usr/bin/python
import sys
import mysql
import mysql.connector as mariadb

# Connect to MariaDB Platform
try:
    cnx = mariadb.connect(user='root', password='xxxxxx', host='localhost', database='xxxx')
except mariadb.Error as e:
    print("Errorcode: {}").format(e)
    sys.exit(1)

# Close Connection
cnx.close()


LXTerminal

root@raspberrypi:~# python sql.py
Errorcode: 2003: Can't connect to MySQL server on 'localhost:3306' (111 Connection refused)
root@raspberrypi:~# 

Ich weiß jetzt nicht mehr weiter, und hoffe das mir jemand hier helfen kann.

Vielen Dank für Eure Hilfe

Answer Answered by Michele Mehlhorn in this comment.

LÖSUNG

Jetzt erstellen wir eine lokale my.cnf- Datei, die die Einstellungen enthält, mit denen wir die Konfiguration im MySQL-Container während der Docker-Laufzeit ändern möchten.

$ nano /Users/[your_username‹/Develop/docker_configs/mysql/my.cnf 

Fügen Sie Ihrer neuen Konfigurationsdatei die folgenden zwei Zeilen hinzu:

[mysqld] 
default-authentication-plugin = mysql_native_password 

Comments

Comments loading...
Content reproduced on this site is the property of its respective owners, and this content is not reviewed in advance by MariaDB. The views, information and opinions expressed by this content do not necessarily represent those of MariaDB or any other party.