centos7下pymysql安装

1.mysql

安装

添加mysql yum respository

添加 MySQL Yum Repository 到你的系统 repository 列表中,执行
wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
yum localinstall mysql-community-release-el7-5.noarch.rpmsql

经过Yum安装mysql

执行命令
yum install mysql-community-server数据库

systemctl start mysqld服务器

 

设置字符集

通常的,为了支持中文,咱们应该讲字符集设为 UTF-8, 执行
SHOW VARIABLES LIKE 'character%';
查看当前 MySQL 字符集spa

mysql> SHOW VARIABLES LIKE 'character%'; +--------------------------+----------------------------+ | Variable_name | Value | +--------------------------+----------------------------+ | character_set_client | utf8 | | character_set_connection | utf8 | | character_set_database | latin1 | | character_set_filesystem | binary | | character_set_results | utf8 | | character_set_server | latin1 | | character_set_system | utf8 | | character_sets_dir | /usr/share/mysql/charsets/ | +--------------------------+----------------------------+ 8 rows in set (0.00 sec

能够看到默认服务器的字符器是 latin1 ,对中文不友好。
修改 /etc/my.cnf 文件,添加字符集的设置.net

[mysqld] character_set_server = utf8 [mysql] default-character-set = utf8

重启 MySQL ,能够看到字符集已经修改了rest

systemctl restart mysqldcode

参考来自:http://blog.csdn.net/whatlookingfor/article/details/52382472#%E8%AE%BE%E7%BD%AE%E5%AD%97%E7%AC%A6%E9%9B%86server

 

新建数据库 create database dbname DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ciblog

新建表 CREATE TABLE test (usr_id INT(10),    test_name CHAR(20),    test_num INT(20))     prim    ENGINE=INNODB DEFAULT CHARSET=utf8;

相关文章
相关标签/搜索