Here are how I connected to phpMyAdmin – MySQL Database
mysql = MySQL()
mysql.init_app(app)
# =====================
import mysql.connector
mydb = mysql.connector.connect(
host="localhost:8889",
unix_socket='/Applications/MAMP/tmp/mysql/mysql.sock',
user="safa",
passwd="safa",
database="safa_task_project"
)