无法使用MySQLWorkbench连接使用dockerfile构build的mysql

dockerfile是:

FROM mysql ENV MYSQL_DATABASE=xxx ENV MYSQL_ROOT_PASSWORD=password ENV MYSQL_ROOT_HOST=172.17.0.1 EXPOSE 3306 

我创build一个图像,它被执行,并在控制台的输出是:

 Initializing database 2017-06-04T21:45:27.614648Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details). 2017-06-04T21:45:28.165234Z 0 [Warning] InnoDB: New log files created, LSN=45790 2017-06-04T21:45:28.239707Z 0 [Warning] InnoDB: Creating foreign key constraint system tables. 2017-06-04T21:45:28.268303Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 1fda3bc6-496f-11e7-b3b9-0242ac110002. 2017-06-04T21:45:28.277209Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened. 2017-06-04T21:45:28.278001Z 1 [Warning] root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option. 2017-06-04T21:45:30.879290Z 1 [Warning] 'user' entry 'root@localhost' ignored in --skip-name-resolve mode. 2017-06-04T21:45:30.879349Z 1 [Warning] 'user' entry 'mysql.sys@localhost' ignored in --skip-name-resolve mode. 2017-06-04T21:45:30.879370Z 1 [Warning] 'db' entry 'sys mysql.sys@localhost' ignored in --skip-name-resolve mode. 2017-06-04T21:45:30.879385Z 1 [Warning] 'proxies_priv' entry '@ root@localhost' ignored in --skip-name-resolve mode. 2017-06-04T21:45:30.879548Z 1 [Warning] 'tables_priv' entry 'sys_config mysql.sys@localhost' ignored in --skip-name-resolve mode. Database initialized Initializing certificates Generating a 2048 bit RSA private key ......+++ ........................................................+++ unable to write 'random state' writing new private key to 'ca-key.pem' ----- Generating a 2048 bit RSA private key ...+++ .................................+++ unable to write 'random state' writing new private key to 'server-key.pem' ----- Generating a 2048 bit RSA private key ....................+++ ..................+++ unable to write 'random state' writing new private key to 'client-key.pem' ----- Certificates initialized MySQL init process in progress... 2017-06-04T21:45:34.509988Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details). 2017-06-04T21:45:34.510828Z 0 [Note] mysqld (mysqld 5.7.18) starting as process 88 ... 2017-06-04T21:45:34.513894Z 0 [Note] InnoDB: PUNCH HOLE support available 2017-06-04T21:45:34.513959Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins 2017-06-04T21:45:34.513962Z 0 [Note] InnoDB: Uses event mutexes 2017-06-04T21:45:34.513964Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier 2017-06-04T21:45:34.513966Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.3 2017-06-04T21:45:34.513968Z 0 [Note] InnoDB: Using Linux native AIO 2017-06-04T21:45:34.514876Z 0 [Note] InnoDB: Number of pools: 1 2017-06-04T21:45:34.515104Z 0 [Note] InnoDB: Using CPU crc32 instructions 2017-06-04T21:45:34.517544Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M 2017-06-04T21:45:34.525700Z 0 [Note] InnoDB: Completed initialization of buffer pool 2017-06-04T21:45:34.528014Z 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority(). 2017-06-04T21:45:34.539849Z 0 [Note] InnoDB: Highest supported file format is Barracuda. 2017-06-04T21:45:34.562076Z 0 [Note] InnoDB: Creating shared tablespace for temporary tables 2017-06-04T21:45:34.562134Z 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ... 2017-06-04T21:45:34.678858Z 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB. 2017-06-04T21:45:34.680707Z 0 [Note] InnoDB: 96 redo rollback segment(s) found. 96 redo rollback segment(s) are active. 2017-06-04T21:45:34.680766Z 0 [Note] InnoDB: 32 non-redo rollback segment(s) are active. 2017-06-04T21:45:34.682159Z 0 [Note] InnoDB: 5.7.18 started; log sequence number 2535558 2017-06-04T21:45:34.682671Z 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool 2017-06-04T21:45:34.683101Z 0 [Note] Plugin 'FEDERATED' is disabled. 2017-06-04T21:45:34.685166Z 0 [Note] InnoDB: Buffer pool(s) load completed at 170604 21:45:34 2017-06-04T21:45:34.696752Z 0 [Note] Found ca.pem, server-cert.pem and server-key.pem in data directory. Trying to enable SSL support using them. 2017-06-04T21:45:34.697436Z 0 [Warning] CA certificate ca.pem is self signed. 2017-06-04T21:45:34.711955Z 0 [Warning] 'user' entry 'root@localhost' ignored in --skip-name-resolve mode. 2017-06-04T21:45:34.712006Z 0 [Warning] 'user' entry 'mysql.sys@localhost' ignored in --skip-name-resolve mode. 2017-06-04T21:45:34.712021Z 0 [Warning] 'db' entry 'sys mysql.sys@localhost' ignored in --skip-name-resolve mode. 2017-06-04T21:45:34.712029Z 0 [Warning] 'proxies_priv' entry '@ root@localhost' ignored in --skip-name-resolve mode. 2017-06-04T21:45:34.713467Z 0 [Warning] 'tables_priv' entry 'sys_config mysql.sys@localhost' ignored in --skip-name-resolve mode. 2017-06-04T21:45:34.718411Z 0 [Note] Event Scheduler: Loaded 0 events 2017-06-04T21:45:34.718587Z 0 [Note] mysqld: ready for connections. Version: '5.7.18' socket: '/var/run/mysqld/mysqld.sock' port: 0 MySQL Community Server (GPL) 2017-06-04T21:45:34.718607Z 0 [Note] Executing 'SELECT * FROM INFORMATION_SCHEMA.TABLES;' to get a list of tables using the deprecated partition engine. You may use the startup option '--disable-partition-engine-check' to skip this check. 2017-06-04T21:45:34.718614Z 0 [Note] Beginning of list of non-natively partitioned tables 2017-06-04T21:45:34.728015Z 0 [Note] End of list of non-natively partitioned tables 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. 2017-06-04T21:45:37.697877Z 5 [Warning] 'user' entry 'root@localhost' ignored in --skip-name-resolve mode. 2017-06-04T21:45:37.697939Z 5 [Warning] 'user' entry 'mysql.sys@localhost' ignored in --skip-name-resolve mode. 2017-06-04T21:45:37.698177Z 5 [Warning] 'db' entry 'sys mysql.sys@localhost' ignored in --skip-name-resolve mode. 2017-06-04T21:45:37.698388Z 5 [Warning] 'proxies_priv' entry '@ root@localhost' ignored in --skip-name-resolve mode. 2017-06-04T21:45:37.698537Z 5 [Warning] 'tables_priv' entry 'sys_config mysql.sys@localhost' ignored in --skip-name-resolve mode. mysql: [Warning] Using a password on the command line interface can be insecure. 2017-06-04T21:45:37.705631Z 0 [Note] Giving 0 client threads a chance to die gracefully 2017-06-04T21:45:37.705651Z 0 [Note] Shutting down slave threads 2017-06-04T21:45:37.705674Z 0 [Note] Forcefully disconnecting 0 remaining clients 2017-06-04T21:45:37.705677Z 0 [Note] Event Scheduler: Purging the queue. 0 events 2017-06-04T21:45:37.705714Z 0 [Note] Binlog end 2017-06-04T21:45:37.706515Z 0 [Note] Shutting down plugin 'ngram' 2017-06-04T21:45:37.706553Z 0 [Note] Shutting down plugin 'BLACKHOLE' 2017-06-04T21:45:37.706560Z 0 [Note] Shutting down plugin 'partition' 2017-06-04T21:45:37.706565Z 0 [Note] Shutting down plugin 'ARCHIVE' 2017-06-04T21:45:37.706700Z 0 [Note] Shutting down plugin 'INNODB_SYS_VIRTUAL' 2017-06-04T21:45:37.706733Z 0 [Note] Shutting down plugin 'INNODB_SYS_DATAFILES' 2017-06-04T21:45:37.706755Z 0 [Note] Shutting down plugin 'INNODB_SYS_TABLESPACES' 2017-06-04T21:45:37.706781Z 0 [Note] Shutting down plugin 'INNODB_SYS_FOREIGN_COLS' 2017-06-04T21:45:37.706942Z 0 [Note] Shutting down plugin 'INNODB_SYS_FOREIGN' 2017-06-04T21:45:37.706974Z 0 [Note] Shutting down plugin 'INNODB_SYS_FIELDS' 2017-06-04T21:45:37.706979Z 0 [Note] Shutting down plugin 'INNODB_SYS_COLUMNS' 2017-06-04T21:45:37.707008Z 0 [Note] Shutting down plugin 'INNODB_SYS_INDEXES' 2017-06-04T21:45:37.707013Z 0 [Note] Shutting down plugin 'INNODB_SYS_TABLESTATS' 2017-06-04T21:45:37.707018Z 0 [Note] Shutting down plugin 'INNODB_SYS_TABLES' 2017-06-04T21:45:37.707040Z 0 [Note] Shutting down plugin 'INNODB_FT_INDEX_TABLE' 2017-06-04T21:45:37.707182Z 0 [Note] Shutting down plugin 'INNODB_FT_INDEX_CACHE' 2017-06-04T21:45:37.707212Z 0 [Note] Shutting down plugin 'INNODB_FT_CONFIG' 2017-06-04T21:45:37.707218Z 0 [Note] Shutting down plugin 'INNODB_FT_BEING_DELETED' 2017-06-04T21:45:37.707223Z 0 [Note] Shutting down plugin 'INNODB_FT_DELETED' 2017-06-04T21:45:37.707228Z 0 [Note] Shutting down plugin 'INNODB_FT_DEFAULT_STOPWORD' 2017-06-04T21:45:37.707407Z 0 [Note] Shutting down plugin 'INNODB_METRICS' 2017-06-04T21:45:37.707429Z 0 [Note] Shutting down plugin 'INNODB_TEMP_TABLE_INFO' 2017-06-04T21:45:37.707434Z 0 [Note] Shutting down plugin 'INNODB_BUFFER_POOL_STATS' 2017-06-04T21:45:37.707456Z 0 [Note] Shutting down plugin 'INNODB_BUFFER_PAGE_LRU' 2017-06-04T21:45:37.707607Z 0 [Note] Shutting down plugin 'INNODB_BUFFER_PAGE' 2017-06-04T21:45:37.707636Z 0 [Note] Shutting down plugin 'INNODB_CMP_PER_INDEX_RESET' 2017-06-04T21:45:37.707658Z 0 [Note] Shutting down plugin 'INNODB_CMP_PER_INDEX' 2017-06-04T21:45:37.707663Z 0 [Note] Shutting down plugin 'INNODB_CMPMEM_RESET' 2017-06-04T21:45:37.707684Z 0 [Note] Shutting down plugin 'INNODB_CMPMEM' 2017-06-04T21:45:37.707820Z 0 [Note] Shutting down plugin 'INNODB_CMP_RESET' 2017-06-04T21:45:37.707850Z 0 [Note] Shutting down plugin 'INNODB_CMP' 2017-06-04T21:45:37.707856Z 0 [Note] Shutting down plugin 'INNODB_LOCK_WAITS' 2017-06-04T21:45:37.707877Z 0 [Note] Shutting down plugin 'INNODB_LOCKS' 2017-06-04T21:45:37.707992Z 0 [Note] Shutting down plugin 'INNODB_TRX' 2017-06-04T21:45:37.708006Z 0 [Note] Shutting down plugin 'InnoDB' 2017-06-04T21:45:37.708201Z 0 [Note] InnoDB: FTS optimize thread exiting. 2017-06-04T21:45:37.708420Z 0 [Note] InnoDB: Starting shutdown... 2017-06-04T21:45:37.809135Z 0 [Note] InnoDB: Dumping buffer pool(s) to /var/lib/mysql/ib_buffer_pool 2017-06-04T21:45:37.810270Z 0 [Note] InnoDB: Buffer pool(s) dump completed at 170604 21:45:37 2017-06-04T21:45:40.157631Z 0 [Note] InnoDB: Shutdown completed; log sequence number 12139694 2017-06-04T21:45:40.166913Z 0 [Note] InnoDB: Removed temporary tablespace data file: "ibtmp1" 2017-06-04T21:45:40.167059Z 0 [Note] Shutting down plugin 'MRG_MYISAM' 2017-06-04T21:45:40.167298Z 0 [Note] Shutting down plugin 'MyISAM' 2017-06-04T21:45:40.167390Z 0 [Note] Shutting down plugin 'CSV' 2017-06-04T21:45:40.167503Z 0 [Note] Shutting down plugin 'MEMORY' 2017-06-04T21:45:40.167541Z 0 [Note] Shutting down plugin 'PERFORMANCE_SCHEMA' 2017-06-04T21:45:40.167599Z 0 [Note] Shutting down plugin 'sha256_password' 2017-06-04T21:45:40.167717Z 0 [Note] Shutting down plugin 'mysql_native_password' 2017-06-04T21:45:40.168032Z 0 [Note] Shutting down plugin 'binlog' 2017-06-04T21:45:40.171056Z 0 [Note] mysqld: Shutdown complete MySQL init process done. Ready for start up. 2017-06-04T21:45:40.451048Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details). 2017-06-04T21:45:40.451891Z 0 [Note] mysqld (mysqld 5.7.18) starting as process 1 ... 2017-06-04T21:45:40.457755Z 0 [Note] InnoDB: PUNCH HOLE support available 2017-06-04T21:45:40.457782Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins 2017-06-04T21:45:40.457786Z 0 [Note] InnoDB: Uses event mutexes 2017-06-04T21:45:40.457788Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier 2017-06-04T21:45:40.457790Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.3 2017-06-04T21:45:40.457795Z 0 [Note] InnoDB: Using Linux native AIO 2017-06-04T21:45:40.458346Z 0 [Note] InnoDB: Number of pools: 1 2017-06-04T21:45:40.458615Z 0 [Note] InnoDB: Using CPU crc32 instructions 2017-06-04T21:45:40.460659Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M 2017-06-04T21:45:40.469391Z 0 [Note] InnoDB: Completed initialization of buffer pool 2017-06-04T21:45:40.471616Z 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority(). 2017-06-04T21:45:40.483436Z 0 [Note] InnoDB: Highest supported file format is Barracuda. 2017-06-04T21:45:40.498521Z 0 [Note] InnoDB: Creating shared tablespace for temporary tables 2017-06-04T21:45:40.498599Z 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ... 2017-06-04T21:45:40.577051Z 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB. 2017-06-04T21:45:40.578116Z 0 [Note] InnoDB: 96 redo rollback segment(s) found. 96 redo rollback segment(s) are active. 2017-06-04T21:45:40.578141Z 0 [Note] InnoDB: 32 non-redo rollback segment(s) are active. 2017-06-04T21:45:40.578560Z 0 [Note] InnoDB: Waiting for purge to start 2017-06-04T21:45:40.628859Z 0 [Note] InnoDB: 5.7.18 started; log sequence number 12139694 2017-06-04T21:45:40.629153Z 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool 2017-06-04T21:45:40.629256Z 0 [Note] Plugin 'FEDERATED' is disabled. 2017-06-04T21:45:40.633930Z 0 [Note] InnoDB: Buffer pool(s) load completed at 170604 21:45:40 2017-06-04T21:45:40.634507Z 0 [Note] Found ca.pem, server-cert.pem and server-key.pem in data directory. Trying to enable SSL support using them. 2017-06-04T21:45:40.634772Z 0 [Warning] CA certificate ca.pem is self signed. 2017-06-04T21:45:40.636787Z 0 [Note] Server hostname (bind-address): '*'; port: 3306 2017-06-04T21:45:40.636867Z 0 [Note] IPv6 is available. 2017-06-04T21:45:40.636871Z 0 [Note] - '::' resolves to '::'; 2017-06-04T21:45:40.636948Z 0 [Note] Server socket created on IP: '::'. 2017-06-04T21:45:40.647855Z 0 [Warning] 'user' entry 'root@localhost' ignored in --skip-name-resolve mode. 2017-06-04T21:45:40.647964Z 0 [Warning] 'user' entry 'mysql.sys@localhost' ignored in --skip-name-resolve mode. 2017-06-04T21:45:40.648018Z 0 [Warning] 'db' entry 'sys mysql.sys@localhost' ignored in --skip-name-resolve mode. 2017-06-04T21:45:40.648026Z 0 [Warning] 'proxies_priv' entry '@ root@localhost' ignored in --skip-name-resolve mode. 2017-06-04T21:45:40.651259Z 0 [Warning] 'tables_priv' entry 'sys_config mysql.sys@localhost' ignored in --skip-name-resolve mode. 2017-06-04T21:45:40.655887Z 0 [Note] Event Scheduler: Loaded 0 events 2017-06-04T21:45:40.656165Z 0 [Note] mysqld: ready for connections. Version: '5.7.18' socket: '/var/run/mysqld/mysqld.sock' port: 3306 MySQL Community Server (GPL) 2017-06-04T21:45:40.656176Z 0 [Note] Executing 'SELECT * FROM INFORMATION_SCHEMA.TABLES;' to get a list of tables using the deprecated partition engine. You may use the startup option '--disable-partition-engine-check' to skip this check. 2017-06-04T21:45:40.656178Z 0 [Note] Beginning of list of non-natively partitioned tables 2017-06-04T21:45:40.664203Z 0 [Note] End of list of non-natively partitioned tables 2017-06-04T21:48:18.537406Z 3 [Note] Access denied for user 'root'@'localhost' (using password: NO) 

我试图连接到数据库使用root用户和diff主机作为本地主机{ContainerID},0.0.0.0,8.8.8.8,172.17.0.1,172.17.0.2,没有运气。 任何人都可以帮我解释为什么我不能连接到数据库吗?

一切都在本地运行。 所以Mysql Db在一个容器中运行,并且MySQLWorkbench工具被安装在我的笔记本电脑中,当我设置MySQLWorkbench以连接到容器内的Mysql时,我收到一条错误消息:连接尝试失败,用户root从主机到服务器172.17。 0.1:3306。 无法提前连接到172.17.0.1(10060)Thx上的MySQL服务器

您需要将-p 3306:3306参数添加到您的docker run命令中。 这将把端口映射到locahost:3306

Interesting Posts