I am trying to connect to my local mysql system using python.
I note that I can only login to my mysql system from the console by sudo /usr/bin/mysql -u root -p
I have looked around the web and am very confused by all the suggestions of which none work for me.
Like I tried
mysql> SELECT User, Host, plugin FROM mysql.user;
Which gives me ...
+------------------+-----------+-----------------------+
| User | Host | plugin |
+------------------+-----------+-----------------------+
| root | localhost | mysql_native_password |
| mysql.session | localhost | mysql_native_password |
| mysql.sys | localhost | mysql_native_password |
| debian-sys-maint | localhost | mysql_native_password |
| keith | localhost | mysql_native_password |
+------------------+-----------+-----------------------+
5 rows in set (0.12 sec)
...
...
import mysql.connector
cnx = mysql.connector.connect(user='root', password='#########',
host='127.0.0.1',
database='SurveyData')
cnx.close()
...
I get the following errors
...
MySQLInterfaceError Traceback (most recent call last)
~/miniconda3/lib/python3.7/site-packages/mysql/connector /connection_cext.py in _open_connection(self)
199 try:
--> 200 self._cmysql.connect(**cnx_kwargs)
201 except MySQLInterfaceError as exc:
MySQLInterfaceError: Access denied for user 'root'@'localhost'
During handling of the above exception, another exception occurred: