修改mysql字符集

vim /etc/my.cnf

 

[mysqld]
datadir = /data/mysql
socket = /var/lib/mysql/mysql.sock

innodb_buffer_pool_size = 1024M
innodb_file_io_threads = 4
innodb_thread_concurrency = 8
innodb_lock_wait_timeout = 120
innodb_file_per_table = 0
innodb_flush_log_at_trx_commit = 2

user = mysql
character-set-client-handshake = FALSE
character-set-server = utf8mb4
collation-server = utf8mb4_unicode_ci
#character-set-server = utf8

log-bin = mysqlbin-log
binlog_format = MIXED
expire_logs_days = 3 
wait_timeout = 300
max_connections = 500

# replication
#replicate-do-db =
replicate-ignore-db = mysql
replicate-ignore-db = test
server-id = 
slave-skip-errors = ALL
log-slave-updates
master-info-file = master.info
relay-log = relay-bin
relay-log-index = relay-bin.index
relay-log-info-file = relay-bin.info


symbolic-links = 0

;plugin-load=rpl_semi_sync_master=semisync_master.so
;plugin-load=rpl_semi_sync_slave=semisync_slave.so
;rpl_semi_sync_master_enabled=1
;rpl_semi_sync_master_timeout=10
;rpl_semi_sync_slave_enabled=1
;performance_schema

slow_query_log_file = /data/mysql/slow.log
long_query_time = 1

pid-file = /data/mysql/mysqld.pid

[mysqld_safe]
log-error = /data/mysql/mysqld.log
pid-file = /data/mysql/mysqld.pid

[mysql]
#default-character-set = utf8
default-character-set = utf8mb4
[client]
default-character-set=utf8mb4

 

重启

 /etc/init.d/mysql    restart

 

建库语句:

CREATE DATABASE xxx_system DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

alter table t_user_info CHANGE user_name user_name varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

 

posted @ 2018-05-28 11:53  南望孤笑  阅读(134)  评论(0编辑  收藏  举报