• 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

  • 相关阅读:
    SQL的运算符优先级
    oracle截取某一个字符之前或之后的值;substr();instr()
    转载-如何成为OpenStack工程师
    入门书籍推荐
    docker学习谈
    mysql学习之旅-主从复制
    LInux断电后无法进入系统报错unexpected inconsistency run fsck manully
    mysqlbinlog读取二进制日志文件时,报错 (转)
    MySQL的binlog详解(转)
    mysql学习之旅-运维手册
  • 原文地址:https://www.cnblogs.com/LinKinSJ/p/15068993.html
Copyright © 2020-2023  润新知