Docker MySQL错误没有'mysql'表

Dmytro Soltusyuk

当我尝试启动容器时,它失败了

日志

➜  enigma git:(master) ✗ docker-compose up --build
Starting db    ... done
Starting nginx ... done
Starting pma   ... done
Attaching to db, nginx, pma
db       | 2020-06-23 08:47:31+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.20-1debian10 started.
nginx    | 2020-06-23 08:47:31+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.20-1debian10 started.
db       | 2020-06-23 08:47:32+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
nginx    | 2020-06-23 08:47:31+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
db       | 2020-06-23 08:47:32+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.20-1debian10 started.
nginx    | 2020-06-23 08:47:31+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.20-1debian10 started.
db       | 2020-06-23T08:47:32.259245Z 0 [Warning] [MY-010139] [Server] Changed limits: max_open_files: 1024 (requested 8161)
db       | 2020-06-23T08:47:32.259248Z 0 [Warning] [MY-010142] [Server] Changed limits: table_open_cache: 431 (requested 4000)
db       | 2020-06-23T08:47:32.569449Z 0 [Warning] [MY-011070] [Server] 'Disabling symbolic links using --skip-symbolic-links (or equivalent) is the default. Consider not using this option as it' is deprecated and will be removed in a future release.
db       | 2020-06-23T08:47:32.569833Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.20) starting as process 1
nginx    | 2020-06-23 08:47:31+00:00 [ERROR] [Entrypoint]: Database is uninitialized and password option is not specified
nginx    |      You need to specify one of MYSQL_ROOT_PASSWORD, MYSQL_ALLOW_EMPTY_PASSWORD and MYSQL_RANDOM_ROOT_PASSWORD
db       | 2020-06-23T08:47:32.632151Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
nginx exited with code 1
db       | 2020-06-23T08:47:38.409327Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
db       | mysqld: Table 'mysql.plugin' doesn't exist
db       | 2020-06-23T08:47:40.082972Z 0 [ERROR] [MY-010735] [Server] Could not open the mysql.plugin table. Please perform the MySQL upgrade procedure.
db       | 2020-06-23T08:47:40.253788Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Socket: '/var/run/mysqld/mysqlx.sock' bind-address: '::' port: 33060
db       | 2020-06-23T08:47:41.287941Z 0 [Warning] [MY-010015] [Repl] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
db       | 2020-06-23T08:47:41.613011Z 0 [Warning] [MY-010015] [Repl] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
pma      | AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.18.0.4. Set the 'ServerName' directive globally to suppress this message
db       | 2020-06-23T08:47:41.858709Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
pma      | AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.18.0.4. Set the 'ServerName' directive globally to suppress this message
db       | 2020-06-23T08:47:42.038096Z 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.
db       | 2020-06-23T08:47:42.039682Z 0 [Warning] [MY-010441] [Server] Failed to open optimizer cost constant tables
db       | 2020-06-23T08:47:42.040884Z 0 [ERROR] [MY-013129] [Server] A message intended for a client cannot be sent there as no client-session is attached. Therefore, we're sending the information to the error-log instead: MY-001146 - Table 'mysql.component' doesn't exist
db       | 2020-06-23T08:47:42.041600Z 0 [Warning] [MY-013129] [Server] A message intended for a client cannot be sent there as no client-session is attached. Therefore, we're sending the information to the error-log instead: MY-003543 - The mysql.component table is missing or has an incorrect definition.
db       | 2020-06-23T08:47:42.044021Z 0 [ERROR] [MY-010326] [Server] Fatal error: Can't open and lock privilege tables: Table 'mysql.user' doesn't exist
db       | 2020-06-23T08:47:42.044832Z 0 [ERROR] [MY-010952] [Server] The privilege system failed to initialize correctly. For complete instructions on how to upgrade MySQL to a new version please see the 'Upgrading MySQL' section from the MySQL manual.
db       | 2020-06-23T08:47:42.046224Z 0 [ERROR] [MY-010119] [Server] Aborting
pma      | [Tue Jun 23 08:47:43.240748 2020] [mpm_prefork:notice] [pid 1] AH00163: Apache/2.4.38 (Debian) PHP/7.4.6 configured -- resuming normal operations
pma      | [Tue Jun 23 08:47:43.241791 2020] [core:notice] [pid 1] AH00094: Command line: 'apache2 -D FOREGROUND'
db       | 2020-06-23T08:47:43.438133Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.20)  MySQL Community Server - GPL.
db exited with code 1 

docker-compose.yml

version: '3'
services:
  db:
    image: mysql:8.0
    volumes:
      - mysqldata:/var/lib/mysql
    command: mysqld --character-set-server=utf8mb4 --collation-server=utf8mb4_general_ci --default-authentication-plugin=mysql_native_password
    container_name: db
    environment:
      MYSQL_USER: root
      MYSQL_ROOT_PASSWORD: root
    ports:
      - 3306:3306
  pma:
    image: phpmyadmin/phpmyadmin
    container_name: pma
    depends_on:
      - db
    environment:
      - PMA_ARBITARY=1
    restart: always
    ports:
      - 8080:80
    volumes:
      - /sessions
  nginx:
    image: nginx
    container_name: nginx
    ports:
      - 80:80
      - 443:443
    # networks: 
    #   static-network:
    #     ipv4_address: 172.20.128.2
volumes:
  mysqldata:
    driver: local
# networks: 
#   static-network:
#     ipam:
#       config: 
#         - subnet: 172.20.0.0/16
Dmytro Soltusyuk

解决的办法是清除体积。来自dmkvl的评论

如果那里没有数据库,我认为您应该删除mysql卷。使用

docker volume ls

列出您的卷,然后

docker volume rm volume_name

删除它。但是请记住,它将删除所有数据!如果在这种情况下有重要数据,则必须在删除卷之前对数据库进行转储。
也可以在此处查看“运行时问题”部分

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章