1. CentOS7安装MySQL
# 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
重启MySQL服务
# service mysqld restart
初次安装mysql,root账户没有密码。
# mysql -u root
设置密码 //可无
mysql> set password for ‘root‘@‘localhost‘ =password(‘password‘);
mysql配置文件为/etc/my.cnf
最后加上编码配置
[mysql]
default-character-set =utf8
远程连接设置
mysql> grant all privileges on *.* to [email protected]‘%‘identified by ‘password‘;
2. 安装MySQL-python模块
1.1 作用
Python操作MySQL需要MySQL-python模块驱动。
1.2 安装MySQL-python
1) 下载地址:https://pypi.python.org/pypi/MySQL-python/
2) 解压:
#unzip MySQL-python-1.2.5.zip
3) 进入文件:
#cd MySQL-python-1.2.5
4) #yum -y install mysql-devel
5) #yum install gcc python-devel
6) #python setup.py install
7) 安装成功,测试:
#python
>>>import MySQLdb
原文地址:https://www.cnblogs.com/Cheng888/p/8519727.html