The reason why I wrote this journal , It's because the installation process is a bit abusive . The current article is aimed at windows On the operating system mysqldb Installation . install python Of mysqldb modular , The first is to find some official websites to download : After downloading ,cmd Get into MySQL-python-1.2.3 Folder , As usual python install Command to install this module , And then it's wrong :

This error report is very obvious ,print

Conduct python front , We should first determine the current mysqldb All versions of support python Which versions of . Some screenshots are as follows :

mysql-python1.2.5 It's the latest version , This version supports mysql3.23-5.5,python2.4-2.7 Of , I won't support it python3 series . Between... Of the current system at the time of installation python yes 3.7.11 Of , At the time of unloading , Wrong report :
  there is a problem with this windows installer package.A programe run as part of the setupdid not finish as expected.Contact your support personnel or package vendor.
       It is estimated that this problem may be caused by file defect , So I tried some solutions on the Internet :
Method 1 : Rerun setup , choice repair, Uninstall after repairing .( result : It's useless ,repair Another network abnormal error is reported when the network is running )
Method 2 : Install a different version of python, And then unload python3.7.11.( result : It's useless , Installing the files generated by the new version will not fix the missing files of the old version )
Method 3 : Delete registry information , Or use Your Unin-staller! Mandatory deletion python3.7.11.( result : Finally, it was deleted successfully ,ps:, There's product registration in the link )
       above 3 There are only three solutions, the third most violent solution to my problem , front 2 Some netizens can use it , It can also solve the problem after operation . Uninstall the higher version of python after , Finally, a lower version of python.

Then install mysqldb, And then I reported a mistake : The lack of c The compiling environment of language , You need to download one VC Environmental Science . This is actually quite easy to do , There is a download link in the error message ( Forget the screenshot , I'm sorry ), Download it VCForPython27.msi Installation will not report this error . But there's another mistake .( I forgot the screenshot again ), And then I think it's necessary to MySQL-python-1.2.3 Look in the folder readme 了 , It usually records how to install and use it . Part about windows The screenshot of the important information of system installation is as follows :

I don't do Windows. But if someone offered me a bag Windows, I'll make it available . Don't ask me about Windows Because I can't help you .
Generally speaking , function Similar to the above ::
C:\ ...> python install C:\ ...> python bdist_wininst
The following example should build a Windows Installation package , If you have the right tools . in any case , You have to have one C compiler . in addition , You have to set an environment variable (mysqlroot) This is a MySQL Installation path . In theory , It will probably get this information from the registry , But like I said ,
I don't do Windows, But I'll accept the patch to do that .

stay Windows On , You must certainly edit site.cfg, Because there are MySQL There's No... in the bag mysql_config.

And then start installing silently mysql, I went to the official website 5.5.7 Version of , Install verification connection DB Always report a mistake :ERROR 1045 (28000): Access denied for user 'mysql'@'localhost' (using password: NO)

This Baidu , In the installation folder my.ini Increase in skip-grant-tables That's all right.

# The TCP/IP Port the MySQL Server will listen on

And then you can connect DB And access DB 了 , Now I think it's ok , However, during installation , Another mistake :

E:\Code\Python\mysql> install
Traceback (most recent call last):
File "E:\Code\Python\mysql\", line , in <module>
metadata, options = get_config()
File "E:\Code\Python\mysql\", line , in get_config
serverKey = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, options['registry_key'])
WindowsError: [Error ]

Possible solutions : open, Then comment out the two lines of code for the registry operation , And add a line of code :

#serverKey = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, options['registry_key'])
#mysql_root, dummy = _winreg.QueryValueEx(serverKey,'Location')
mysql_root = "C:\Program Files\MySQL\MySQL Server 5.5" #MySQL Catalog

And then install , Another mistake :

Possible solutions : download MySQL Connector( Address : ), And then modify Code for :

#serverKey = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, options['registry_key'])
#mysql_root, dummy = _winreg.QueryValueEx(serverKey,'Location')
mysql_root = "C:\Program Files\MySQL\MySQL Connector C 6.0.2" #MySQL Connector C 6.0.2 Catalog <span style="color:#ff0000;">

Then perform the installation , Oh my god , It's a success .

import MySQLdb
if __name__ == "__main__":
test= MySQLdb.connect("localhost","root","root1234","mysql" )
cur = test.cursor()
cur.execute('show databases;')
for data in cur.fetchall():
print data

The results are as follows :

D:\Python27\python.exe D:/untitled/
('test',) Process finished with exit code

Learn before RF When I installed a third-party library, I have never been so cruel , It is also possible that the original version used at that time was a lower version python, And at that time, there were various compiling environments for programs on the machine , But there's a problem , There is no common way to install the third-party library quickly , Based on the experience of dog blood , Make the following summary :
1、 Take a look at the installation file before installation read me And download some instructions on the page ( Generally, the author will write installation manual and test Document , No matter what kind of operating system it is, it will be introduced more or less ).

2、 determine python Tripartite library supports python Which version of , Now look at python2.7.11 It's still very good .

3、 Determine which other environments and dependent software are needed when installing the third-party library .

python And mysqldb More articles on module installation

  1. Python Of MySQLdb Module installation

    MySQL-python-1.2.1.tar.gz   Download address : Then decompress , open README( This one doesn't really work ) There's the installation process : ...

  2. Python Of MySQLdb Module installation , Connect , operation , Additions and deletions

    1. First of all confirm python The version is 2.3.4 above , If it doesn't need to be upgraded python Version of      python -V   Check python edition 2. install mysql, For example, install in /usr/local/my ...

  3. stay mac Installation on system python Of MySQLdb modular

    stay mac Installation on system python Of MySQLdb modular In particular : This article mainly referred to Mac How to install the system MySQLdb(MySQL-Python) The first 1 Step : download MySQL-python-1.2 ...

  4. Mac MySQLdb Module installation , It's solved

    Reprint : Short commentary : This article is a comprehensive solution Mac MySQLdb Module installation problem article , special ...

  5. python in MySQLdb Examples of module usage

    This article mainly introduces python in MySQLdb Module usage , In the form of an example, this paper describes in detail MySQLdb Module for MySQL Various common operation methods of database , Very practical value , Friends in need can refer to This article gives an example of python in ...

  6. Python Third party module installation of

    python Third party module installation generally uses python Built-in tools pip To install . 1. stay Windows Next , In the installation python When checking [ install pip] and [ add to python To environment variables ]. If in python Installation directory ...

  7. Python in MySQLdb Module installation

    install MySQLdb yes Python Language access mysql A module of the database , If you're not sure about your Python Whether this module has been installed in the environment , Can open Python shell, Input import MySQLdb, Such as ...

  8. python Of MySQLdb Modules in linux Installation in environment

    Begin to learn python After database programming , After understanding the basic concepts , I'm going to try it out , It's stuck MYSQLdb Package installation , It took a long time to solve it . Make a note that I'm in linux Problems encountered installing this package in . System is ubuntn15.04. 1 ...

  9. Mac OS X Lower installation python Of MySQLdb modular

    Reference material : mac os x Next python install MySQLdb modular MAC OSX Use Python Installation module related issues  http:// ...

Random recommendation

  1. Daily direction blog Development record

    A little bit of history about ,Sonne Blog 2016.03.25springmvc + hibernate Frame building .2016.04.21 Daily direction blog home page .2016.04.24 Paging implementation .2016.04.30 Sign in ...

  2. Maven Install local jar

    Application scenarios : Sometimes some jar package ( such as oracle Of ojdbc.jar) For a variety of reasons , Such as copyright, etc , Lead to maven The central library doesn't have the jar file , But there is something to do jar Of pom file . This is the time , If private clothes don't have this jar ...

  3. Mobile platform automation testing starts from scratch -MonkeyRunner Tool use ( In the second quarter )

    selected from : The first 2 section  MonkeyRunner Installation and deployment If you have installed and deployed correctly A ...

  4. ORACLE Consistent reading principle records

    What is consistent reading ? Consistent reading means that from the moment of query , Ignore the changes in the middle . Illustrate with examples For example, I have two accounts A,B. A Yes 1000 block ,B Yes 1000 fast . When I query, the query speed is relatively slow . middle A turn 500 To B Account . already ...

  5. &lt; Make a good test of yourself &gt;mac os install mcrypt Expand

    Previously installed opencart I don't need to mcrypt This library . But the new version needs . Add your own yes mac Environmental Science . I was in trouble , It's never been installed . Let's think about it this afternoon ! 1. First you have to install xcode This tool . Otherwise, No ...

  6. Once a day LeetCode--237.Delete Node in a Linked List

    Write a function to delete a node (except the tail) in a singly linked list, given only access to th ...

  7. Rolling parallax effect ——background-attachment

    The principle of scrolling parallax effect is to divide page elements into multiple layers on the same page , For example, it can be divided into background . Content . Map layer , When scrolling the page, let the three scroll at different speeds , So as to form a three-dimensional approximate effect in human vision . I've been working on a project recently wiki When the ...

  8. Security scan tool -AppScan

    AppScan The main function is to scan the page security tool

  9. wpf Interface thread Add item

    foreach (var r in sec.Records) { listView.Dispatcher.Invoke((new Action(delegate() { listView.Items. ...

  10. win7 64 A professional version of x64 Compilation problems

    stay Django In the development process , There's a problem , The number of bits in all local libraries must be the same , So some libraries need to be recompiled , The work environment , You can't use pirated programs ,VC++ 2008\2010 Express Version itself does not support X64 Compilation of ...