To import the user accounts and passwords in the blog into the FTP database, you can directly use the blog account to log on to FTP. I decided to use python in Linux to help me deal with it. This log is a brief introduction, using python to connect to Mysql.
1. Install the MySQLdb module in Linux
To connect to Mysql using python, you need an interface for connecting python to Mysql, which is the MySQLdb module.
Functions of MySQLdb:
MySQL support for Python. mySQL versions 3.23-5.1; and Python versions 2.3-2.5 are supported. mySQLdb is the Python DB API-2.0 interface. _ mysql is a low-level API similiar to the MySQL c api. ZMySQLDA is a Database Adapter for Zope2.
In the operating system of red-flag Linux, the MySQL-python module with version 1.0.0 is used by default:
Reference
# Rpm-qa | grep MySQL
MySQL-python-1.0.0-1.RHEL4.1
However, it is found that the version of this module is too old, and the support for Mysql 4.1 or above is incomplete, and even a Bug exists in help. Therefore, we recommend that you upgrade to a new version.
1. Install the new version
You can download and compile it by yourself. You can also use the compiled rpm package:
See the final attachment.
※This rpm package is applicable to systems with the red-flag DC Server 5.0 for x86 SP2 and python 2.3. Compile and use other systems on your own.
In addition, the MySQLdb module of version 1.2.2 cannot be compiled successfully on CentOS 5 and used on CentOS 5. You can use its own version 1.2.1.
2. Compile and install
The python and Mysql versions supported by MySQLdb of the new version 1.2.2 are different from those of the old version. See the README file in the source code.
If you do not use the rpm Method for installation, You can manually compile and install the command as follows:
# Cd/usr/local/src/MySQL-python-1.2.2/
# Python setup. py build
# Python setup. py install
If you do not have the setuptools module in your python environment, you must connect to the Internet during compilation. It will download the setuptools module from the Internet and generate a. egg compression module file for future use.