zoukankan      html  css  js  c++  java
  • docker 部署mysql连接问题

    发现windows上有一个docker descktop(虽然不怎么好用), 安装之后准备直接用docker搭本地测试环境的基础设施(比如MySQL,Redis,MongoDB,ES啥的), 虽然比去到处找安装包安装来的好, 不过这样就体会不到自己装软件的乐趣了(滑稽.jpg)
    首先是安装MySQL, 遇到了几个问题, 记录下

    mysql镜像用的是最新版的, docker search mysql可以看大很多版本的, 我用的是第一个使用量最多那个(稳妥)

    1. 启动时未指定相关环境变量

      docker desktop to specify one of the following:

      • -MYSQL_ROOT_PASSWORD
      • -MYSQL_ALLOW_EMPTY_PASSWORD
      • -MYSQL_RANDOM_ROOT_PASSWORD

      docker run -dit --restart always --name mysql-docker -e MYSQL_RANDOM_ROOT_PASSWORD=your-password -e MYSQL_ALLOW_EMPTY_PASSWORD=TRUE-e MYSQL_ROOT_PASSWORD=your-password -p 3308:3306 mysql

    2. 查看mysql启动时生成的密码

    3. 通过密码连接mysql

      Public Key Retrieval is not allowed异常
      连接时需要设置SSL, docker中的mysql镜像在运行过程中默认开启了SSL


    启动日志

    2021-07-28 01:31:54+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.26-1debian10 started.
    2021-07-28 01:31:54+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
    2021-07-28 01:31:54+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.26-1debian10 started.
    2021-07-28 01:31:54+00:00 [Note] [Entrypoint]: Initializing database files
    2021-07-28T01:31:54.823283Z 0 [System] [MY-013169] [Server] /usr/sbin/mysqld (mysqld 8.0.26) initializing of server in progress as process 43
    2021-07-28T01:31:54.834337Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
    2021-07-28T01:31:55.703399Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
    2021-07-28T01:31:58.007570Z 0 [Warning] [MY-013746] [Server] A deprecated TLS version TLSv1 is enabled for channel mysql_main
    2021-07-28T01:31:58.008365Z 0 [Warning] [MY-013746] [Server] A deprecated TLS version TLSv1.1 is enabled for channel mysql_main
    2021-07-28T01:31:58.079942Z 6 [Warning] [MY-010453] [Server] root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.
    2021-07-28 01:32:03+00:00 [Note] [Entrypoint]: Database files initialized
    2021-07-28 01:32:03+00:00 [Note] [Entrypoint]: Starting temporary server
    mysqld will log errors to /var/lib/mysql/04c2f13e03d1.err
    mysqld is running as pid 94
    2021-07-28 01:32:03+00:00 [Note] [Entrypoint]: Temporary server started.
    Warning: Unable to load '/usr/share/zoneinfo/iso3166.tab' as time zone. Skipping it.
    Warning: Unable to load '/usr/share/zoneinfo/leap-seconds.list' as time zone. Skipping it.
    Warning: Unable to load '/usr/share/zoneinfo/zone.tab' as time zone. Skipping it.
    Warning: Unable to load '/usr/share/zoneinfo/zone1970.tab' as time zone. Skipping it.
    2021-07-28 01:32:07+00:00 [Note] [Entrypoint]: GENERATED ROOT PASSWORD: at8Tunah6phudongieworerufaishaih
    2021-07-28 01:32:07+00:00 [Note] [Entrypoint]: Stopping temporary server
    2021-07-28 01:32:09+00:00 [Note] [Entrypoint]: Temporary server stopped
    2021-07-28 01:32:09+00:00 [Note] [Entrypoint]: MySQL init process done. Ready for start up.
    2021-07-28T01:32:09.511023Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.26) starting as process 1
    2021-07-28T01:32:09.523510Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
    2021-07-28T01:32:09.718660Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
    2021-07-28T01:32:09.914244Z 0 [Warning] [MY-013746] [Server] A deprecated TLS version TLSv1 is enabled for channel mysql_main
    2021-07-28T01:32:09.914533Z 0 [Warning] [MY-013746] [Server] A deprecated TLS version TLSv1.1 is enabled for channel mysql_main
    2021-07-28T01:32:09.916163Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
    2021-07-28T01:32:09.916535Z 0 [System] [MY-013602] [Server] Channel mysql_main configured to support TLS. Encrypted connections are now supported for this channel.
    2021-07-28T01:32:09.922148Z 0 [Warning] [MY-011810] [Server] Insecure configuration for --pid-file: Location '/var/run/mysqld' in the path is accessible to all OS users. Consider choosing a different directory.
    2021-07-28T01:32:09.943246Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Bind-address: '::' port: 33060, socket: /var/run/mysqld/mysqlx.sock
    2021-07-28T01:32:09.943351Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.0.26' socket: '/var/run/mysqld/mysqld.sock' port: 3306 MySQL Community Server - GPL.
    mbind: Operation not permitted
    mbind: Operation not permitted

  • 相关阅读:
    操作 Java 数组的 12 个最佳方法
    详解 JavaScript 中 splice() 方法
    Java 读取 .properties 配置文件的几种方式
    表单中单选、多选、选择框值的获取及表单的序列化
    一个调出上下文菜单的实例
    跨浏览器的事件侦听器和事件对象
    动态加载js和css
    php语言实现的7种基本的排序方法
    CORS(跨源资源共享)实战
    ubuntu中LAMP环境搭建及ubuntu语言和输入法设置
  • 原文地址:https://www.cnblogs.com/LinKinSJ/p/15068993.html
Copyright © 2011-2022 走看看