title: I am getting error "Access denied for user 'root'@'localhost" when trying to use Connector/Python
body: <p>I am trying to connect to my local mysql system using python.</p>
  
  <p>I note that I can only login to my mysql system from the console by
  sudo /usr/bin/mysql -u root -p</p>
  
  <p>I have looked around the web and am very confused by all the suggestions of which none work for me.</p>
  
  <p>Like I tried </p>
  
  <pre><code>mysql&gt; SELECT User, Host, plugin FROM mysql.user;
  </code></pre>
  
  <p>Which gives me 
  ...</p>
  
  <pre><code>+------------------+-----------+-----------------------+
  | 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)
  </code></pre>
  
  <p>...</p>
  
  <p>...</p>
  
  <pre><code>import mysql.connector
  
  cnx = mysql.connector.connect(user='root', password='#########',
                            host='127.0.0.1',
                            database='SurveyData')
  cnx.close()
  </code></pre>
  
  <p>...</p>
  
  <p>I get the following errors</p>
  
  <p>...</p>
  
  <pre><code>MySQLInterfaceError                       Traceback (most recent call last)
  ~/miniconda3/lib/python3.7/site-packages/mysql/connector  /connection_cext.py in _open_connection(self)
      199         try:
  --&gt; 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:
  </code></pre>