how to connect a python code to database using mysql
<p>I am using below code for connectivity:</p>

<pre><code>    import MySQLdb



db = MySQLdb.connect("localhost","root","root","test" )


cursor = db.cursor()


cursor.execute("SELECT * from student")


data = cursor.fetchone()
print "Database result : %s " % data


db.close()
</code></pre>

<p>i am getting  below error during running the file:</p>

<pre><code>Traceback (most recent call last):
File "C:/Python27/xsxs.py", line 5, in &lt;module&gt;
db = MySQLdb.connect("localhost","root","root","test" )
File "C:\Python27\lib\site-packages\MySQLdb\__init__.py", line 81, in Connect
return Connection(*args, **kwargs)
File "C:\Python27\lib\site-packages\MySQLdb\connections.py", line 187, in __init__
super(Connection, self).__init__(*args, **kwargs2)
OperationalError: (2003, "Can't connect to MySQL server on 'localhost' (10061)")
</code></pre>

<p>How can i solve it.</p>
