This article mainly introduces the installation method of the mysqldb module of Python under Windows. Friends who need it can refer to it.
The reason why I wrote this log is because the installation process is a bit sad. This article is currently aimed at the installation of mysqldb on Windows operating systems. To install the mysqldb module of Python, of course, first find some official websites to download: https://pypi.python.org/pypi/MySQL-python. After downloading, cmd into the MySQL-python-1.2.3 folder, execute the python setup.py install command as usual to install this module, and then an error is reported:
This The error is obvious, print
Before running python, you should first determine which versions of python are supported by each version of mysqldb. Some screenshots are as follows:
mysql-python1.2.5 is the latest version. This version supports mysql3.23-5.5, python2.4-2.7, but does not support python3. series. During the installation, the current system's Python is 3.7.11. When uninstalling, an error is reported:
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.
I guess this problem may be caused by file defects, so I tried some solutions mentioned on the Internet:
Method 1: Rerun the installer, select repair, and then uninstall after repairing. (Result: useless, another network exception error was reported during repair)
Method 2: Install a different version of python, and then uninstall python3.7.11. (Result: useless, the files generated by installing the new version will not repair the old ones. Missing version file)
Method 3: Delete the registry information, or use Your Unin-staller! to forcefully delete python3.7.11. (Result: The deletion was finally successful,
ps: http:/ /wenku.baidu.com/link?url=dujEO65nXySNvwUyDJVR5kmbrlcqp7WsvhLFGN_7L5q-58EoVjyw4DjiTS_J5PomPzgvdG69uulXDI8TbMgJlXk9Y-ayHs8qOD3Z3AomBU7, there is product registration in the link)
or this article: http://www .jb51.net/softjc/500307.html
Of the above 3 solutions, only the third and most violent method solved my problem. Some netizens can use the first 2 methods, and the problem can be solved after operation. After uninstalling the higher version of python, I finally installed the lower version of python.
Then I installed mysqldb, and then another error was reported: the c language compilation environment is missing, and I need to download a VC environment. This is actually quite easy to handle. There is a download link in the error message (I forgot to take a screenshot, sorry) https://www.microsoft.com/en-us/download/confirmation.aspx?id=44266. Download VCForPython27.msi This error will not be reported after installation. But another error is reported. (I forgot to take a screenshot again), and then I felt it was necessary to check the readme in the MySQL-python-1.2.3 folder. It usually records how to install and how to use it. The translated screenshots of some important information about Windows system installation are as follows:
Windows....... 我不做Windows。 但是如果有人给我提供了一个包Windows,我会使它可用。 不要问我有关Windows的帮助因为我不能帮助你。 一般来说,运行setup.py与上面类似:: C:\ ...> python setup.py install C:\ ...> python setup.py bdist_wininst 后面的示例应该构建一个Windows安装程序包,如果你有正确的工具。 无论如何,你必须有一个C编译器。另外,你必须设置一个环境变量(mysqlroot)这是MySQL安装的路径。 在理论上,它会的可能从注册表中获取这些信息,但是像我说的, 我不做Windows,但我会接受这样做的补丁。 在Windows上,您肯定必须编辑site.cfg,因为有在MySQL包中没有mysql_config。
Then I started to install mysql silently, went to the official website and downloaded version 5.5.7, and installed and verified the connection. DB always reports an error: ERROR 1045 (28000): Access denied for user 'mysql'@'localhost' (using password: NO)
In this Baidu, add skip- in my.ini in the installation folder Just grant-tables
[mysqld] skip-grant-tables # The TCP/IP Port the MySQL Server will listen on port=3306
Then you can connect to the DB normally and access the DB. Now I think there should be no problem. However, during installation, another error was reported. :
E:\Code\Python\mysql>setup.py install Traceback (most recent call last): File "E:\Code\Python\mysql\setup.py", line 15, in <module> metadata, options = get_config() File "E:\Code\Python\mysql\setup_windows.py", line 7, in get_config serverKey = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, options['registry_key']) WindowsError: [Error 2]
Possible solution: Open setup_windows.py, then comment out the two lines of code for registry operations, and add one 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目录
Then continued the installation, and another error was reported:
Possible solution: Download MySQL Connector (Address: http:// dev.mysql.com/get/Downloads/Connector-C/mysql-connector-c-6.0.2-win32.msi/from/http://ftp.jaist.ac.jp/pub/mysql/), and then modify Code of setup_windows.py:
#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目录
Then execute the installation, my God, it finally succeeded.
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 print result is as follows:
D:\Python27\python.exe D:/untitled/mysql_test.py ('information_schema',) ('mysql',) ('performance_schema',) ('test',) Process finished with exit code 0
I have installed third-party libraries when I was learning RF but never like this I'm sad, it's possible that I was using a low version of python at that time, and there were compilation environments for various programs on the machine at that time. However, a problem was exposed, that is, when installing third-party libraries, there was no universal method to help with quick installation. Based on The bloody experience is summarized as follows:
1. Before installation, read the read me in the installation file and some instructions on the download page (generally the author will write the installation manual and test document, no matter what type it is) The operating system will be introduced more or less).
2. Determine which version of python is supported by the python third-party library. Currently, python2.7.11 is pretty good.
3. Determine what other environments and dependent software are needed when installing the third-party library.
The above is the detailed content of How to install python's mysqldb module under windows. For more information, please follow other related articles on the PHP Chinese website!

MySQLoffersvariousstorageengines,eachsuitedfordifferentusecases:1)InnoDBisidealforapplicationsneedingACIDcomplianceandhighconcurrency,supportingtransactionsandforeignkeys.2)MyISAMisbestforread-heavyworkloads,lackingtransactionsupport.3)Memoryengineis

Common security vulnerabilities in MySQL include SQL injection, weak passwords, improper permission configuration, and unupdated software. 1. SQL injection can be prevented by using preprocessing statements. 2. Weak passwords can be avoided by forcibly using strong password strategies. 3. Improper permission configuration can be resolved through regular review and adjustment of user permissions. 4. Unupdated software can be patched by regularly checking and updating the MySQL version.

Identifying slow queries in MySQL can be achieved by enabling slow query logs and setting thresholds. 1. Enable slow query logs and set thresholds. 2. View and analyze slow query log files, and use tools such as mysqldumpslow or pt-query-digest for in-depth analysis. 3. Optimizing slow queries can be achieved through index optimization, query rewriting and avoiding the use of SELECT*.

To monitor the health and performance of MySQL servers, you should pay attention to system health, performance metrics and query execution. 1) Monitor system health: Use top, htop or SHOWGLOBALSTATUS commands to view CPU, memory, disk I/O and network activities. 2) Track performance indicators: monitor key indicators such as query number per second, average query time and cache hit rate. 3) Ensure query execution optimization: Enable slow query logs, record and optimize queries whose execution time exceeds the set threshold.

The main difference between MySQL and MariaDB is performance, functionality and license: 1. MySQL is developed by Oracle, and MariaDB is its fork. 2. MariaDB may perform better in high load environments. 3.MariaDB provides more storage engines and functions. 4.MySQL adopts a dual license, and MariaDB is completely open source. The existing infrastructure, performance requirements, functional requirements and license costs should be taken into account when choosing.

MySQL uses a GPL license. 1) The GPL license allows the free use, modification and distribution of MySQL, but the modified distribution must comply with GPL. 2) Commercial licenses can avoid public modifications and are suitable for commercial applications that require confidentiality.

The situations when choosing InnoDB instead of MyISAM include: 1) transaction support, 2) high concurrency environment, 3) high data consistency; conversely, the situation when choosing MyISAM includes: 1) mainly read operations, 2) no transaction support is required. InnoDB is suitable for applications that require high data consistency and transaction processing, such as e-commerce platforms, while MyISAM is suitable for read-intensive and transaction-free applications such as blog systems.

In MySQL, the function of foreign keys is to establish the relationship between tables and ensure the consistency and integrity of the data. Foreign keys maintain the effectiveness of data through reference integrity checks and cascading operations. Pay attention to performance optimization and avoid common errors when using them.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

Atom editor mac version download
The most popular open source editor

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

SublimeText3 English version
Recommended: Win version, supports code prompts!

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.
