Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/dart/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Docker mysql容器不允许远程连接_Mysql_Docker - Fatal编程技术网

Docker mysql容器不允许远程连接

Docker mysql容器不允许远程连接,mysql,docker,Mysql,Docker,我在尝试从mysql客户端连接到远程计算机上已停靠的mysql服务器时,用户“bonus_user”@“my-ip”(使用密码:YES)的访问被拒绝。出现错误 我的docker撰写文件: bonus_db: container_name: bonus_db image: mysql:5.7 command: --default-authentication-plugin=mysql_native_password restart: unless-stopped ports: -

我在尝试从mysql客户端连接到远程计算机上已停靠的mysql服务器时,用户“bonus_user”@“my-ip”(使用密码:YES)的访问被拒绝。出现错误

我的docker撰写文件:

bonus_db:
 container_name: bonus_db
 image: mysql:5.7
 command: --default-authentication-plugin=mysql_native_password
 restart: unless-stopped
 ports:
   - "3306:3306"
 environment:
   MYSQL_USER: bonus_user
   MYSQL_PASSWORD: bonus_pass
   MYSQL_DATABASE: bonus_db
   MYSQL_ROOT_PASSWORD: root_pass
volumes:
  - /var/lib/volumes/bonusdata:/var/lib/mysql
以下是容器启动的日志:

bonus_db    | 2020-11-14 15:06:05+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 5.7.31-1debian10 started.
bonus_db    | 2020-11-14 15:06:05+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
bonus_db    | 2020-11-14 15:06:05+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 5.7.31-1debian10 started.
bonus_db    | 2020-11-14T15:06:06.470897Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
bonus_db    | 2020-11-14T15:06:06.480712Z 0 [Note] mysqld (mysqld 5.7.31) starting as process 1 ...
bonus_db    | 2020-11-14T15:06:06.502124Z 0 [Note] InnoDB: PUNCH HOLE support available
bonus_db    | 2020-11-14T15:06:06.504807Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
bonus_db    | 2020-11-14T15:06:06.504851Z 0 [Note] InnoDB: Uses event mutexes
bonus_db    | 2020-11-14T15:06:06.504878Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
bonus_db    | 2020-11-14T15:06:06.504894Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
bonus_db    | 2020-11-14T15:06:06.504906Z 0 [Note] InnoDB: Using Linux native AIO
bonus_db    | 2020-11-14T15:06:06.505684Z 0 [Note] InnoDB: Number of pools: 1
bonus_db    | 2020-11-14T15:06:06.506021Z 0 [Note] InnoDB: Using CPU crc32 instructions
bonus_db    | 2020-11-14T15:06:06.522229Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
bonus_db    | 2020-11-14T15:06:06.548073Z 0 [Note] InnoDB: Completed initialization of buffer pool
bonus_db    | 2020-11-14T15:06:06.554315Z 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
bonus_db    | 2020-11-14T15:06:06.568903Z 0 [Note] InnoDB: Highest supported file format is Barracuda.
bonus_db    | 2020-11-14T15:06:06.603166Z 0 [Note] InnoDB: Creating shared tablespace for temporary tables
bonus_db    | 2020-11-14T15:06:06.605892Z 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
bonus_db    | 2020-11-14T15:06:06.654737Z 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
bonus_db    | 2020-11-14T15:06:06.656736Z 0 [Note] InnoDB: 96 redo rollback segment(s) found. 96 redo rollback segment(s) are active.
bonus_db    | 2020-11-14T15:06:06.656771Z 0 [Note] InnoDB: 32 non-redo rollback segment(s) are active.
bonus_db    | 2020-11-14T15:06:06.657961Z 0 [Note] InnoDB: Waiting for purge to start
bonus_db    | 2020-11-14T15:06:06.708340Z 0 [Note] InnoDB: 5.7.31 started; log sequence number 13750567
bonus_db    | 2020-11-14T15:06:06.709023Z 0 [Note] Plugin 'FEDERATED' is disabled.
bonus_db    | 2020-11-14T15:06:06.711205Z 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
bonus_db    | 2020-11-14T15:06:06.715836Z 0 [Note] InnoDB: Buffer pool(s) load completed at 201114 15:06:06
bonus_db    | 2020-11-14T15:06:06.721862Z 0 [Note] Found ca.pem, server-cert.pem and server-key.pem in data directory. Trying to enable SSL support using them.
bonus_db    | 2020-11-14T15:06:06.721918Z 0 [Note] Skipping generation of SSL certificates as certificate files are present in data directory.
bonus_db    | 2020-11-14T15:06:06.723943Z 0 [Warning] CA certificate ca.pem is self signed.
bonus_db    | 2020-11-14T15:06:06.724051Z 0 [Note] Skipping generation of RSA key pair as key files are present in data directory.
bonus_db    | 2020-11-14T15:06:06.725417Z 0 [Note] Server hostname (bind-address): '*'; port: 3306
bonus_db    | 2020-11-14T15:06:06.725502Z 0 [Note] IPv6 is available.
bonus_db    | 2020-11-14T15:06:06.725525Z 0 [Note]   - '::' resolves to '::';
bonus_db    | 2020-11-14T15:06:06.725562Z 0 [Note] Server socket created on IP: '::'.
bonus_db    | 2020-11-14T15:06:06.740164Z 0 [Warning] Insecure configuration for --pid-file: Location '/var/run/mysqld' in the path is accessible to all OS users. Consider choosing a different directory.
bonus_db    | 2020-11-14T15:06:06.765251Z 0 [Note] Event Scheduler: Loaded 0 events
bonus_db    | 2020-11-14T15:06:06.765978Z 0 [Note] mysqld: ready for connections.
bonus_db    | Version: '5.7.31'  socket: '/var/run/mysqld/mysqld.sock'  port: 3306  MySQL Community Server (GPL)
我尝试以如下方式登录到远程计算机上的容器:

docker exec -i bonus_db mysql -ubonus_user -pbonus_pass
这似乎很有效,因为如果我在这里传递了错误的密码,它将给出相同的错误
拒绝访问
。我还尝试从sql文件导入数据

docker exec -i bonus_db mysql -ubonus_user -pbonus_pass bonus_db < dump.sql
docker exec-i bonus\u db mysql-ubonus\u user-pbonus\u pass bonus\u db

它似乎也在工作,它处理了几秒钟,然后退出到终端。但我无法从本地计算机和其他容器访问数据库。

好吧,您是否授予任何用户外部访问权限?您如何尝试连接到它?您遇到了什么错误?@DavidMaze我正在尝试通过DBeaver连接,用户'bonus\u user'@'my-ip'的访问被拒绝(使用密码:是)
请编辑问题以添加这些详细信息。请确保包含您尝试连接时使用的设置(主机名、端口、用户名),并澄清客户端是在Docker中运行、在同一主机上运行还是在其他地方运行。@OneCricketeer我想它已经被授予了权限,下面是
SHOW GRANTS for bonus\u user的输出
将**上的使用权授予“奖金用户”@“%