Can't connect to mysql using python's mysql.connector
Question: I'm using a Mac (OS 10.10.5), PyCharm, Python 3.5 and MySQL. MySQL has been
working with PHP on the same machine. I'm trying to connect to it using Python
and getting the error message: `enter code here`2003: Can't connect to MySQL
server on 'localhost::3306' (8 nodename nor servname provided, or not known)

Can someone list the diagnostic steps so I can correct the problem? Thanks,
Doug

Below is the connection code: import mysql.connector from mysql.connector
import errorcode

    
    
    try:
    cnn = mysql.connector.connect(
        host="localhost:",  # your host, usually localhost
        user="root",  # your username
        password="root",  # your password
        database="bb_cards")  # name of the data base
    print("It Works!!")
    except mysql.connector.Error as e:
    if e.errno == errorcode.ER_ACCESS_DENIED_ERROR:
        print("Something is wrong with username or Password")
    elif e.errno == errorcode.ER_BAD_DB_ERROR:
        print("Database Does not exist")
    else:
        print(e)
    


Answer: You have a colon where there shouldn't be one:

    
    
    host="localhost:" # remove the : ->  host="localhost" 
    

`127.0.0.1::3306` is not the same as `127.0.0.1:3306`

