I set up a MySQL database on Ubuntu 18.04, and am trying to connect via python using mysql.connector
. The database is on the same computer as the instance of python (Acer predator).
Connecting to the MySQL database through the terminal works. But using mysql.connector
in python 3.6 keeps producing the following error:
mysql.connector.errors.ProgrammingError: 1698 (28000): Access denied for user 'root'@'localhost'
I keep seeing troubleshooting tips talking about auth_socket or granting privileges even here in Stack Overflow, but these are all focused on connecting with MySQL, whereas my issue is specific to mysql.connector
in python.
Code I am using is below, and I've tried it with other users, no password included, and even no host included - but nothing works.
import mysql.connector
conn = mysql.connector.connect(host='localhost',
database='exampledatabase',
user='root',
password='examplepassword')