How to connect to MySQL without using a password? (PyMySQL)

Here is the relevant part of my code:

        try:
            if self.pass_entry.get():
                self.connection = pymysql.connect(
                    host=self.host_entry.get(),
                    user=self.user_entry.get(),
                    password=self.pass_entry.get(),
                    db=self.db_entry.get(),
                    charset="utf8mb4",
                    cursorclass=pymysql.cursors.DictCursor
                )
            else:
                self.connection = pymysql.connect(
                    host=self.host_entry.get(),
                    user=self.user_entry.get(),
                    db=self.db_entry.get(),
                    charset="utf8mb4",
                    cursorclass=pymysql.cursors.DictCursor
                )
        except Exception as e:
            self.console.insert(tk.END, "Error: {err}\n".format(err=str(e)))

Here's the error:

Connecting to 127.0.0.1...
Error: (1045, "Access denied for user 'root'@'localhost' (using password: YES)")

There is no password for "root", and PyMySQL assumes that it is. How can I connect without using a password? (I tried to omit the password parameter when the password field / line is empty, but PyMySQL does not take this into account).

+4
source share

All Articles