Python learning notes-database usage (1), python learning notes

Source: Internet
Author: User

Python learning notes-database usage (1), python learning notes
1. Install MySQL on CentOS7

# Wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm

# Rpm-ivh mysql-community-release-el7-5.noarch.rpm

# Yum install mysql-community-server

 

Restart MySQL Service

# Service mysqld restart

 

The first time mysql is installed, the root account does not have a password.

# Mysql-u root

 

Set Password // none

Mysql> set password for 'root' @ 'localhost' = password ('Password ');

 

The mysql configuration file is/etc/my. cnf.

Add the encoding Configuration

[Mysql]

Default-character-set = utf8

 

Remote connection settings

Mysql> grant all privileges on *. * to root @ '%' identified by 'Password ';

2. Install the MySQL-python Module  1.1 Role

Python requires the MySQL-python module driver to operate MySQL.

1.2 install MySQL-python

1): https://pypi.python.org/pypi/MySQL-python/

2) decompress:

# Unzip MySQL-python-1.2.5.zip

3) enter the file:

# Cd MySQL-python-1.2.5

4) # yum-y install mysql-devel

5) # yum install gcc python-devel

6) # python setup. py install

7) the installation is successful. test:

# Python

>>> Import MySQLdb

Related Article

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.