title: cursor() raise errors.OperationalError("MySQL Connection not available.") OperationalError: MySQL Connection not available
body: <pre><code>import requests
  import time
  import csv
  import ast
  import sys
  import mysql.connector
  
  config = {
  'user': 'root',
  'password': 'password',
  'host': '127.0.0.1',
  'port': '3306',
  'database': 'dbname',
  'raise_on_warnings': True,}
  
  cnx = mysql.connector.connect(config)    
  cursor = cnx.cursor()
  </code></pre>
  
  <p>Running gives:</p>
  
  <pre><code>Traceback (most recent call last):
    File "/home/ubuntu/scrapers/xrp2.py", line 17, in &lt;module&gt;
      cursor = cnx.cursor()
    File "/usr/local/lib/python2.7/dist-packages/mysql/connector/connection.py", line 1383, in cursor
      raise errors.OperationalError("MySQL Connection not available.")
  OperationalError: MySQL Connection not available.
  </code></pre>
  
  <p>Does anyone know how to fix this? Other forums have had similar errors and fixed the problem by not having too many cursors open, but this is the first call to <code>cursor()</code>, so I'm not sure why it's unavailable. Do I need to close MySQL from the Ubuntu terminal? </p>
  
  <p>My config file  works fine connecting via Sequel Pro's SSH.</p>
  
  <p>SOLVED: Put the configuration into the .connect(statement) instead of as a dictionary.</p>
  
  <pre><code>import requests
  import mysql.connector
  
  cnx = mysql.connector.connect(user ='root', password= 'p', host = '127.0.0.1',port='3306', database='coindb')
  
  cursor = cnx.cursor()
  </code></pre>