docker 安装mysql5.7 mysql开启binlog mysql忽略大小写设置

1、拉取mysql镜像
docker pull mysql:5.7

2、创建lm2路径,用于映射容器中mysql数据
mkdir lm2
3、运行mysql --privileged=true这个赋予容器操作权限
docker run -d -p 13306:3306 -v /lm2:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=123456 --privileged=true --name mysql01 mysql:5.7 --lower_case_table_names=1
4、查看运行中容器
docker ps -a
5、进入容器内部
docker exec -it 0be4d499443b /bin/bash
6、编辑mysql配置文件
vim /etc/mysql/mysql.conf.d/mysqld.cnf
添加:
log-bin=/var/lib/mysql/mysql-bin
server-id=123454
lower_case_table_names=1

7、重启docker
docker restart 0be4d499443b
8、进入容器 docker exec -it 0be4d499443b /bin/bash
9、进入mysql : mysql -u root -p
10、输入密码:123456
11、查看binlog是否开启:show variables like ‘log_%’;
mysql> show variables like ‘log_%’;
±---------------------------------------±-------------------------------+
| Variable_name | Value |
±---------------------------------------±-------------------------------+
| log_bin | ON |
| log_bin_basename | /var/lib/mysql/mysql-bin |
| log_bin_index | /var/lib/mysql/mysql-bin.index |
| log_bin_trust_function_creators | OFF |
| log_bin_use_v1_row_events | OFF |
| log_builtin_as_identified_by_password | OFF |
| log_error | stderr |
| log_error_verbosity | 3 |
| log_output | FILE |
| log_queries_not_using_indexes | OFF |
| log_slave_updates | OFF |
| log_slow_admin_statements | OFF |
| log_slow_slave_statements | OFF |
| log_statements_unsafe_for_binlog | ON |
| log_syslog | OFF |
| log_syslog_facility | daemon |
| log_syslog_include_pid | ON |
| log_syslog_tag | |
| log_throttle_queries_not_using_indexes | 0 |
| log_timestamps | UTC |
| log_warnings | 2 |
±---------------------------------------±-------------------------------+

12、查看是否忽略大小写:show global variables like ‘%lower_case%’;

mysql> show global variables like ‘%lower_case%’;
±-----------------------±------+
| Variable_name | Value |
±-----------------------±------+
| lower_case_file_system | OFF |
| lower_case_table_names | 1 |
±-----------------------±------+

13、授予远程权限:
GRANT ALL PRIVILEGES ON . TO ‘root’@‘%’ IDENTIFIED BY ‘123456’ WITH GRANT OPTION;
14、刷新权限:
flush privileges;
15、navicat 连接测试

你可能感兴趣的:(docker,mysql,容器)