Docker安装MySQL(OpenWRT)

参考文章:

Docker安装MySQL(含open | D-y Blog

第一步、拉取镜像

docker pull mysql:5.7

docker pull mysql:latest

安装你的需求去安装版本

第二步、docker代码

docker run -d --name mysql -p 3306:3306 --privileged=true -v /usr/local/mysql/log:/var/log/mysql -v /usr/local/mysql/data:/var/lib/mysql -v /usr/local/mysql/conf:/etc/mysql/conf.d -e MYSQL_ROOT_PASSWORD=123456  mysql:latest

/usr/local/mysql/ 本地文件根目录

/usr/local/mysql/conf 配置修改地址

/usr/local/mysql/data 数据保存位置

第三步、修改my.cnf

vim /usr/local/mysql/conf/my.cnf
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html
# *** DO NOT EDIT THIS FILE. It's a template which will be copied to the
# *** default location during install, and will be replaced if you
# *** upgrade to a newer version of MySQL.
[client]
default-character-set=utf8
[mysqld]
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
 
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
# These are commonly set, remove the # and set as required.
# basedir = .....
# datadir = .....
# port = .....
# server_id = .....
# socket = .....
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
default-storage-engine=InnoDB
character-set-server=utf8mb4
collation-server=utf8mb4_general_ci
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

完成第三步后重启容器

docker restart mysql

第四步、登录MySQL

docker exec -it mysql /bin/bash

登录MySQL

mysql -uroot -p

密码:123456

MYSQL_ROOT_PASSWORD=123456 #可以自定义

查看字符集

show variables like 'character%';

 

使用Navicat Premium 15连接

 

更多MySQL相关设置

Linux安装MySQL5.7.x | D-y Blog 

相关推荐

  1. docker安装

    2024-01-07 22:14:03       53 阅读
  2. 安装Docker

    2024-01-07 22:14:03       73 阅读
  3. docker 安装

    2024-01-07 22:14:03       52 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-01-07 22:14:03       94 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-01-07 22:14:03       101 阅读
  3. 在Django里面运行非项目文件

    2024-01-07 22:14:03       82 阅读
  4. Python语言-面向对象

    2024-01-07 22:14:03       91 阅读

热门阅读

  1. JCraft实现远程服务器的登录和文件上传下载删除

    2024-01-07 22:14:03       59 阅读
  2. okhttp网络请求工具

    2024-01-07 22:14:03       55 阅读
  3. Flutter 中的 Stream:异步编程的利器

    2024-01-07 22:14:03       55 阅读
  4. 华为HCIE课堂笔记第十二章 ICMPv6和NDP协议

    2024-01-07 22:14:03       55 阅读
  5. C++中的面向对象重点总结

    2024-01-07 22:14:03       69 阅读
  6. C#VB.net如何增加WinForms中复选框的大小?

    2024-01-07 22:14:03       64 阅读
  7. DOS小白手册(DOS的基本使用)

    2024-01-07 22:14:03       54 阅读
  8. Autosar PNC网络管理配置(1)-基于ETAS软件

    2024-01-07 22:14:03       58 阅读