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

到此这篇关于docker 部署mysql连接问题的文章就介绍到这了,更多相关docker 部署mysql内容请搜索www.887551.com以前的文章或继续浏览下面的相关文章希望大家以后多多支持www.887551.com!

(0)
上一篇 2022年3月21日
下一篇 2022年3月21日

相关推荐