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 i ...
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 root@'%'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