[root@localhost ~]# docker exec -it mysql bash Error response from daemon: Container 86a52dd7c0252d6ec55e365dc6aa199be5f6d682112d7f2f3341fb2e8fecb283 is restarting, wait until the container is running
(1)查看容器是否启动
1 2 3 4
[root@localhost ~]# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 86a52dd7c025 mysql "docker-entrypoint.s…" 13 minutes ago Restarting (1) 32 seconds ago mysql
[root@localhost ~]# docker logs --tail 50 --follow --timestamps mysql 2025-01-20T08:20:26.734594188Z mysqld: [ERROR] Stopped processing the 'includedir' directive in file /etc/my.cnf at line 32. 2025-01-20T08:20:26.734698588Z mysqld: [ERROR] Fatal error in defaults handling. Program aborted! 2025-01-20T08:20:40.377050799Z 2025-01-20 08:20:40+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 9.1.0-1.el9 started. 2025-01-20T08:20:40.419462151Z 2025-01-20 08:20:40+00:00 [ERROR] [Entrypoint]: mysqld failed while attempting to check config 2025-01-20T08:20:40.419505081Z command was: mysqld --verbose --help --log-bin-index=/tmp/tmp.8250f3JkdC 2025-01-20T08:20:40.419515251Z mysqld: Can't read dir of '/etc/mysql/conf.d/' (OS errno 2 - No such file or directory) 2025-01-20T08:20:40.419549450Z mysqld: [ERROR] Stopped processing the 'includedir' directive in file /etc/my.cnf at line 32. 2025-01-20T08:20:40.419563941Z mysqld: [ERROR] Fatal error in defaults handling. Program aborted! 2025-01-20T08:21:13.680145697Z 2025-01-20 08:21:13+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 9.1.0-1.el9 started. 2025-01-20T08:21:13.717457825Z 2025-01-20 08:21:13+00:00 [ERROR] [Entrypoint]: mysqld failed while attempting to check config 2025-01-20T08:21:13.717596515Z command was: mysqld --verbose --help --log-bin-index=/tmp/tmp.TYh3CpN1u8 2025-01-20T08:21:13.717636655Z mysqld: Can't read dir of '/etc/mysql/conf.d/' (OS errno 2 - No such file or directory) 2025-01-20T08:21:13.717798115Z mysqld: [ERROR] Stopped processing the 'includedir' directive in file /etc/my.cnf at line 32. 2025-01-20T08:21:13.717837625Z mysqld: [ERROR] Fatal error in defaults handling. Program aborted! 2025-01-20T08:22:05.745368974Z 2025-01-20 08:22:05+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 9.1.0-1.el9 started. 2025-01-20T08:22:05.789739896Z 2025-01-20 08:22:05+00:00 [ERROR] [Entrypoint]: mysqld failed while attempting to check config 2025-01-20T08:22:05.789822966Z command was: mysqld --verbose --help --log-bin-index=/tmp/tmp.C05n80Ysco 2025-01-20T08:22:05.789859597Z mysqld: Can't read dir of '/etc/mysql/conf.d/' (OS errno 2 - No such file or directory) 2025-01-20T08:22:05.789893527Z mysqld: [ERROR] Stopped processing the 'includedir' directive in file /etc/my.cnf at line 32. 2025-01-20T08:22:05.789927187Z mysqld: [ERROR] Fatal error in defaults handling. Program aborted! 2025-01-20T08:23:12.645946982Z 2025-01-20 08:23:12+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 9.1.0-1.el9 started. 2025-01-20T08:23:12.684595612Z 2025-01-20 08:23:12+00:00 [ERROR] [Entrypoint]: mysqld failed while attempting to check config 2025-01-20T08:23:12.684630352Z command was: mysqld --verbose --help --log-bin-index=/tmp/tmp.1rB9VCkp64 2025-01-20T08:23:12.684640702Z mysqld: Can't read dir of '/etc/mysql/conf.d/' (OS errno 2 - No such file or directory) 2025-01-20T08:23:12.684649972Z mysqld: [ERROR] Stopped processing the 'includedir' directive in file /etc/my.cnf at line 32. 2025-01-20T08:23:12.684659332Z mysqld: [ERROR] Fatal error in defaults handling. Program aborted! 2025-01-20T08:24:24.216607747Z 2025-01-20 08:24:24+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 9.1.0-1.el9 started. 2025-01-20T08:24:24.257900368Z 2025-01-20 08:24:24+00:00 [ERROR] [Entrypoint]: mysqld failed while attempting to check config 2025-01-20T08:24:24.257941768Z command was: mysqld --verbose --help --log-bin-index=/tmp/tmp.6GSe4KbVW1 2025-01-20T08:24:24.257954068Z mysqld: Can't read dir of '/etc/mysql/conf.d/' (OS errno 2 - No such file or directory) 2025-01-20T08:24:24.257965368Z mysqld: [ERROR] Stopped processing the 'includedir' directive in file /etc/my.cnf at line 32. 2025-01-20T08:24:24.257976968Z mysqld: [ERROR] Fatal error in defaults handling. Program aborted! 2025-01-20T08:25:29.659499906Z 2025-01-20 08:25:29+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 9.1.0-1.el9 started. 2025-01-20T08:25:29.700926926Z 2025-01-20 08:25:29+00:00 [ERROR] [Entrypoint]: mysqld failed while attempting to check config 2025-01-20T08:25:29.701021426Z command was: mysqld --verbose --help --log-bin-index=/tmp/tmp.a8mWSG80iJ 2025-01-20T08:25:29.701061526Z mysqld: Can't read dir of '/etc/mysql/conf.d/' (OS errno 2 - No such file or directory) 2025-01-20T08:25:29.701099426Z mysqld: [ERROR] Stopped processing the 'includedir' directive in file /etc/my.cnf at line 32. 2025-01-20T08:25:29.701290726Z mysqld: [ERROR] Fatal error in defaults handling. Program aborted! 2025-01-20T08:26:34.665746987Z 2025-01-20 08:26:34+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 9.1.0-1.el9 started. 2025-01-20T08:26:34.706785408Z 2025-01-20 08:26:34+00:00 [ERROR] [Entrypoint]: mysqld failed while attempting to check config 2025-01-20T08:26:34.706926808Z command was: mysqld --verbose --help --log-bin-index=/tmp/tmp.iW6BztAeCU 2025-01-20T08:26:34.707219808Z mysqld: Can't read dir of '/etc/mysql/conf.d/' (OS errno 2 - No such file or directory) 2025-01-20T08:26:34.707260608Z mysqld: [ERROR] Stopped processing the 'includedir' directive in file /etc/my.cnf at line 32. 2025-01-20T08:26:34.707302108Z mysqld: [ERROR] Fatal error in defaults handling. Program aborted! 2025-01-20T08:27:39.135705165Z 2025-01-20 08:27:39+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 9.1.0-1.el9 started. 2025-01-20T08:27:39.176601786Z 2025-01-20 08:27:39+00:00 [ERROR] [Entrypoint]: mysqld failed while attempting to check config 2025-01-20T08:27:39.176695586Z command was: mysqld --verbose --help --log-bin-index=/tmp/tmp.6Qbbqnndbq 2025-01-20T08:27:39.176736686Z mysqld: Can't read dir of '/etc/mysql/conf.d/' (OS errno 2 - No such file or directory) 2025-01-20T08:27:39.176774786Z mysqld: [ERROR] Stopped processing the 'includedir' directive in file /etc/my.cnf at line 32. 2025-01-20T08:27:39.176812086Z mysqld: [ERROR] Fatal error in defaults handling. Program aborted!
其中:主要下面几种报错循环报错
1 2 3 4 5
2025-01-20T08:26:34.707302108Z mysqld: [ERROR] Fatal error in defaults handling. Program aborted! 2025-01-20T08:27:39.135705165Z 2025-01-20 08:27:39+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 9.1.0-1.el9 started. 2025-01-20T08:27:39.176601786Z 2025-01-20 08:27:39+00:00 [ERROR] [Entrypoint]: mysqld failed while attempting to check config 2025-01-20T08:27:39.176695586Z command was: mysqld --verbose --help --log-bin-index=/tmp/tmp.6Qbbqnndbq 2025-01-20T08:27:39.176736686Z mysqld: Can't read dir of '/etc/mysql/conf.d/' (OS errno 2 - No such file or directory) #这个报错指不能找到conf.d文件
从上面报错信息可以看出 mysqld: Can’t read dir of ‘/etc/mysql/conf.d/‘ (无法读取/etc/mysql/conf.d/目录)。这样就知道原因了,mysql找不到conf.d目录。所以启动容器时指定到conf.d目录
#创建一个新的用户或者授权现有用户(如果已存在): CREATE USER 'root'@'%' IDENTIFIED BY 'password'; #或者 GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION; #刷新权限: FLUSH PRIVILEGES; #其中,'root'@'%'表示任何IP地址的客户端都可以用root用户连接到服务器,'password'是你为root用户设置的密码。 #请确保你的防火墙允许3306端口(或你自定义的MySQL端口)的入站连接。