0

import MySQLdb
db = MySQLdb.connect(host = "localhost",user = "root",passwd = " ",db = "TESTDB" )
cursor = db.cursor()
sql = """CREATE TABLE CRAWLER (
FIRST_NAME CHAR(20) NOT NULL,
LAST_NAME CHAR(20),
AGE INT,
SEX CHAR(1),
INCOME FLOAT )"""
cursor.execute(sql)
db.close()

when i execute this code there is an error occure like
OperationalError: (1045, "Access denied for user 'root'@'localhost' (using password: YES)")

what can i do? pls clarify this....

2
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by muthulazmi
0

import MySQLdb
db = MySQLdb.connect(host = "localhost",user = "root",passwd = " ",db = "TESTDB" )
cursor = db.cursor()
sql = """CREATE TABLE CRAWLER (
FIRST_NAME CHAR(20) NOT NULL,
LAST_NAME CHAR(20),
AGE INT,
SEX CHAR(1),
INCOME FLOAT )"""
cursor.execute(sql)
db.close()

when i execute this code there is an error occure like
OperationalError: (1045, "Access denied for user 'root'@'localhost' (using password: YES)")

what can i do? pls clarify this....

Code tags, please!

Are you sure that roots password is one space and not for example empty ""?

import MySQLdb
db = MySQLdb.connect(host = "localhost",user = "root",passwd = " ",db = "TESTDB" )
cursor = db.cursor()
sql = """CREATE TABLE CRAWLER (
         FIRST_NAME  CHAR(20) NOT NULL,
         LAST_NAME  CHAR(20),
         AGE INT,  
         SEX CHAR(1),
         INCOME FLOAT )"""
cursor.execute(sql)
db.close()
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.