0
import mysql.connector

conn = mysql.connector.connect(host="localhost", user="root", password="")

if conn.is_connected():
    print("Successful")
else:
    print("Not Successful")`

I think my everything is ok in environment variable setup, mysql is also running in the system, python works properly, xampp also works well, the value of host, user are also correct. But I am unable to connect with Mysql using python. This is not even showing any error. There comes no output at all. Output Whenever I run the program, I get no output at all, I am pretty much sure the problem is happening in the second line. but not sure what is happening and how to solve.

I tried using Mysql workbench, doesn't work. I am expecting to control my database from this python program

7
  • Why are you passing the -u flag? Commented Oct 21, 2024 at 14:18
  • I am not passing it, I am clicking on 'Run Code' using mouse. It is automatically calling this. Commented Oct 21, 2024 at 14:23
  • which version of mysql is being used? also which version of the mysql connector? Commented Oct 21, 2024 at 14:25
  • mysql version: mysql Ver 15.1 Distrib 10.4.32-MariaDB, for Win64 (AMD64), source revision c4143f909528e3fab0677a28631d10389354c491 connector version: mysql-connector-python 9.1.0 Commented Oct 21, 2024 at 14:27
  • can you try without the -u? Commented Oct 21, 2024 at 14:32

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.