1.mysql
添加 MySQL Yum Repository 到你的系統 repository 列表中,執行
wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
yum localinstall mysql-community-release-el7-5.noarch.rpm
sql
執行命令
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;