首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Docker MySQL错误没有“mysql”表

Docker MySQL错误没有“mysql”表
EN

Ask Ubuntu用户
提问于 2020-06-23 08:57:50
回答 2查看 6.3K关注 0票数 0

当我试图引导容器时,它失败了

日志

代码语言:javascript
运行
复制
➜  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

代码语言:javascript
运行
复制
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
EN

回答 2

Ask Ubuntu用户

回答已采纳

发布于 2020-06-23 13:43:30

解决办法是清除音量。来自dmkvl的评论

如果您没有dbs,我认为您应该删除mysql卷。使用停靠卷ls列出卷,然后使用停靠卷rm volume_name删除卷。但请记住,它将删除所有的数据!如果在本例中有重要数据,则必须在删除卷之前对数据库进行转储。还查看了“运行时问题”部分这里

票数 1
EN

Ask Ubuntu用户

发布于 2020-06-23 09:34:37

我看到了这些错误。您还没有说明docker正在运行的主机操作系统。我发现,对于linux来说,/var/lib/mysql必须是ext4和MacOS APFS。由于限制,exfat不起作用。我从mysql切换到mariadb,因为它占用的空间更小。此外,初始化我的数据库的脚本也是链接的。

代码语言:javascript
运行
复制
db:
   container_name: db
   image: mariadb
   command: --default-authentication-plugin=mysql_native_password
   networks:
     - htpc-network
   environment:
     MYSQL_ROOT_PASSWORD: xxx
   restart: unless-stopped
   volumes: 
     - ${PLEX}/sniff:/var/lib/mysql
     - ./db:/docker-entrypoint-initdb.d
   ports: 
     - "3306:3306"

db/01_create_database.sql

代码语言:javascript
运行
复制
create database sniffer;
create user 'pi' identified by 'xxx';
create user sniffer identified by 'xxx';
grant all on sniffer.* to 'pi';
grant all on sniffer.* to 'sniffer';
票数 0
EN
页面原文内容由Ask Ubuntu提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://askubuntu.com/questions/1253026

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档