码迷,mamicode.com
首页 > 数据库 > 详细

docker mysql 文件挂载和MySQL字符集设置

时间:2017-07-07 00:54:57      阅读:1159      评论:0      收藏:0      [点我收藏+]

标签:doc   设置   字符集   file   show   mysql字符集   names   word   base   

docker run -p 3306:3306 --name mysql -v /usr/local/mysql/my.cnf:/etc/mysql/my.cnf -v /usr/local/mysql/logs:/logs -v /usr/local/mysql/data:/mysql_data -e MYSQL_ROOT_PASSWORD=root -d mysql:5.6

  • -p 3306:3306:将容器的3306端口映射到主机的3306端口

  • -v $PWD/conf/my.cnf:/etc/mysql/my.cnf:将主机当前目录下的conf/my.cnf挂载到容器的/etc/mysql/my.cnf

  • -v $PWD/logs:/logs:将主机当前目录下的logs目录挂载到容器的/logs

  • -v $PWD/data:/mysql_data:将主机当前目录下的data目录挂载到容器的/mysql_data

  • -e MYSQL_ROOT_PASSWORD=123456:初始化root用户的密码

 

 

show variables like‘character%‘;  # 查看MySQL的字符集

+--------------------------+----------------------------+
| Variable_name | Value |
+--------------------------+----------------------------+
| character_set_client | latin1 |
| character_set_connection | latin1 |
| character_set_database | utf8 |
| character_set_filesystem | binary |
| character_set_results | latin1 |
| character_set_server | utf8 |
| character_set_system | utf8 |
| character_sets_dir | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+

 

修改字MySQL字符集    vim /etc/my.cnf

[client]
default-character-set=utf8
 
[mysql]
default-character-set=utf8
 
[mysqld]
init_connect=‘SET collation_connection = utf8_unicode_ci‘
init_connect=‘SET NAMES utf8‘
character-set-server=utf8
collation-server=utf8_unicode_ci
skip-character-set-client-handshake

docker mysql 文件挂载和MySQL字符集设置

标签:doc   设置   字符集   file   show   mysql字符集   names   word   base   

原文地址:http://www.cnblogs.com/trydoit/p/7129039.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!