[Very depressed]python2.7 connection mysql5.5 configuration

Source: Internet
Author: User
Tags win32

Today, the Python version on the company's computer is the same as the one on his home computer, unlike the MySQL company version 5.6, which took two days without the configuration of Python and MySQL.

Simply said Python connection MySQL has been reported 2003 error, the error code is: (2003, "Can ' t, connect to MySQL server on ' localhost ' (10061)"

Baidu on the internet for a day still did not find a solution, seemingly mysql5.6 up, its configuration changed, anyway, the company computer on the MySQL service startup, through the cmd input Netstat-ano view MySQL port use, the results found its localadress:: 1, Seems to be IPv6 address, to the present do not know how to solve.

Back home, think of online a senior said that really can't change a version of the MySQL bar, so home in their own computer configuration as follows:

Python-2.7.10.msi install, and then add the installation path in path

Mysql-5.5.46-win32.msi: Install, then add the installation path in path, then refer to the previous article, "Install MySQL under Windows"

Mysql-python-1.2.3.win32-py2.7.exe: Install directly, then import MYSQLDB is installed correctly

Test Python connection actually no problem, really no language! (Of course, with cmd input Netstat-ano view MySQL port localadress is 127.0.0.1, this is the normal situation)

Body:

After installing the previous three, write a py script file that reads as follows:

Import MySQLdb
Conn=mysqldb.connect (
host= ' localhost ', #127.0.0.1 can also
port=3306,
User= ' Root ',
Passwd= ' 123456 ',
db= ' MySQL ',
)
Cur=conn.cursor ()
Cur.execute ("Select VERSION ();")
data = Cur.fetchone ()
Print "Database version:%s"% data

F5 run the script, output database version:5.5.46, it seems absolutely no problem ah.

Finally, if the connection is invalid, please send a private messages, thank you! ):

python-2.7.10.msi:https://www.python.org/downloads/windows/

mysql-5.5.46-win32.msi:http://dev.mysql.com/downloads/file/?id=458972

Mysql-python-1.2.3.win32-py2.7.exe:http://vdisk.weibo.com/s/awz3drpb3yfxo

[Very depressed]python2.7 connection mysql5.5 configuration

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.