start mysql instance with empty password

이창주·2023년 6월 18일
0

Backend

목록 보기
5/7

mysql docker를 최초로 실행하면 다음과같은 오류메시지를 볼 수 있다.
초기 암호가 설정되지 않아서인데, 여기서는 초기 암호를 설정하는 방법이 아닌 empty password로 mysql db를 생성하는 방법을 설명한다.

docker-compose.yml 파일은 다음과 같이 구성되어 있고,

services:
  mysql:
    image: mysql:5.7
    networks:
      - internal
    volumes:
      - "./volumes/mysql:/var/lib/mysql"
    #container_name: "mysql"
    restart: unless-stopped
    ports:
      - "3306:3306"
    #environment:
    #  - MYSQL_ALLOW_EMPTY_PASSWORD=true
    

mysql instance를 최초로 실행하면 다음과 같이 암호가 설정되어 있지 않다는 오류메시지를 볼 수 있다.

$ docker-compose up mysql

mysql-1  | 2023-06-18 03:53:52+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
mysql-1  | 2023-06-18 03:53:52+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 5.7.39-1.el7 started.
mysql-1  | 2023-06-18 03:53:52+00:00 [ERROR] [Entrypoint]: Database is uninitialized and password option is not specified
mysql-1  |     You need to specify one of the following:
mysql-1  |     - MYSQL_ROOT_PASSWORD
mysql-1  |     - MYSQL_ALLOW_EMPTY_PASSWORD
mysql-1  |     - MYSQL_RANDOM_ROOT_PASSWORD

여기서는 empty password로 mysql을 생성하도록 한다.

$ docker compose run -e MYSQL_ALLOW_EMPTY_PASSWORD=true mysql

[+] Running 1/1
 ⠿ Container mysql-1  Recreated                                                                                                                  0.1s
Attaching to mysql-1
mysql-1  | 2023-06-18 03:55:48+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 5.7.39-1.el7 started.
mysql-1  | 2023-06-18 03:55:48+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
mysql-1  | 2023-06-18 03:55:48+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 5.7.39-1.el7 started.
mysql-1  | 2023-06-18 03:55:48+00:00 [Note] [Entrypoint]: Initializing database files
mysql-1  | 2023-06-18T03:55:48.994646Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
mysql-1  | 2023-06-18T03:55:49.015542Z 0 [Warning] Setting lower_case_table_names=2 because file system for /var/lib/mysql/ is case insensitive
mysql-1  | 2023-06-18T03:56:10.493977Z 0 [Warning] InnoDB: New log files created, LSN=45790

mysql-1  | 2023-06-18T03:56:14.759108Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.

mysql-1  | 2023-06-18T03:56:15.039997Z 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: 12673281-0d8c-11ee-8694-0242c0a88003.
mysql-1  | 2023-06-18T03:56:15.052005Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
mysql-1  | 2023-06-18T03:56:15.307874Z 0 [Warning] A deprecated TLS version TLSv1 is enabled. Please use TLSv1.2 or higher.
mysql-1  | 2023-06-18T03:56:15.307934Z 0 [Warning] A deprecated TLS version TLSv1.1 is enabled. Please use TLSv1.2 or higher.
mysql-1  | 2023-06-18T03:56:15.323211Z 0 [Warning] CA certificate ca.pem is self signed.
mysql-1  | 2023-06-18T03:56:15.544387Z 1 [Warning] root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.
mysql-1  | 2023-06-18 03:56:42+00:00 [Note] [Entrypoint]: Database files initialized
mysql-1  | 2023-06-18 03:56:42+00:00 [Note] [Entrypoint]: Starting temporary server
mysql-1  | 2023-06-18 03:56:42+00:00 [Note] [Entrypoint]: Waiting for server startup
mysql-1  | 2023-06-18T03:56:42.201196Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
mysql-1  | 2023-06-18T03:56:42.215754Z 0 [Note] mysqld (mysqld 5.7.39) starting as process 124 ...
mysql-1  | 2023-06-18T03:56:42.229880Z 0 [Warning] Setting lower_case_table_names=2 because file system for /var/lib/mysql/ is case insensitive
mysql-1  | 2023-06-18T03:56:42.231672Z 0 [Note] InnoDB: PUNCH HOLE support available
mysql-1  | 2023-06-18T03:56:42.231730Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
mysql-1  | 2023-06-18T03:56:42.231749Z 0 [Note] InnoDB: Uses event mutexes
mysql-1  | 2023-06-18T03:56:42.231852Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
mysql-1  | 2023-06-18T03:56:42.231867Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.12
mysql-1  | 2023-06-18T03:56:42.231882Z 0 [Note] InnoDB: Using Linux native AIO
mysql-1  | 2023-06-18T03:56:42.232094Z 0 [Note] InnoDB: Number of pools: 1
mysql-1  | 2023-06-18T03:56:42.232259Z 0 [Note] InnoDB: Using CPU crc32 instructions
mysql-1  | 2023-06-18T03:56:42.234400Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
mysql-1  | 2023-06-18T03:56:42.243588Z 0 [Note] InnoDB: Completed initialization of buffer pool
mysql-1  | 2023-06-18T03:56:42.246143Z 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
mysql-1  | 2023-06-18T03:56:42.400005Z 0 [Note] InnoDB: Highest supported file format is Barracuda.
mysql-1  | 2023-06-18T03:56:42.696993Z 0 [Note] InnoDB: Creating shared tablespace for temporary tables
mysql-1  | 2023-06-18T03:56:42.706384Z 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
mysql-1  | 2023-06-18T03:56:44.856393Z 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
mysql-1  | 2023-06-18T03:56:44.866175Z 0 [Note] InnoDB: 96 redo rollback segment(s) found. 96 redo rollback segment(s) are active.
mysql-1  | 2023-06-18T03:56:44.866244Z 0 [Note] InnoDB: 32 non-redo rollback segment(s) are active.
mysql-1  | 2023-06-18T03:56:44.867289Z 0 [Note] InnoDB: 5.7.39 started; log sequence number 2756207
mysql-1  | 2023-06-18T03:56:44.867505Z 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
mysql-1  | 2023-06-18T03:56:44.868416Z 0 [Note] Plugin 'FEDERATED' is disabled.
mysql-1  | 2023-06-18T03:56:45.146049Z 0 [Note] Found ca.pem, server-cert.pem and server-key.pem in data directory. Trying to enable SSL support using them.
mysql-1  | 2023-06-18T03:56:45.146119Z 0 [Note] Skipping generation of SSL certificates as certificate files are present in data directory.
mysql-1  | 2023-06-18T03:56:45.146129Z 0 [Warning] A deprecated TLS version TLSv1 is enabled. Please use TLSv1.2 or higher.
mysql-1  | 2023-06-18T03:56:45.146139Z 0 [Warning] A deprecated TLS version TLSv1.1 is enabled. Please use TLSv1.2 or higher.
mysql-1  | 2023-06-18T03:56:45.184567Z 0 [Warning] CA certificate ca.pem is self signed.
mysql-1  | 2023-06-18T03:56:45.184895Z 0 [Note] Skipping generation of RSA key pair as key files are present in data directory.
mysql-1  | 2023-06-18T03:56:45.216963Z 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.
mysql-1  | 2023-06-18T03:56:45.354405Z 0 [Note] InnoDB: Buffer pool(s) load completed at 230618  3:56:45
mysql-1  | 2023-06-18T03:56:46.026307Z 0 [Note] Event Scheduler: Loaded 0 events
mysql-1  | 2023-06-18T03:56:46.027154Z 0 [Note] mysqld: ready for connections.
mysql-1  | Version: '5.7.39'  socket: '/var/run/mysqld/mysqld.sock'  port: 0  MySQL Community Server (GPL)
mysql-1  | 2023-06-18 03:56:46+00:00 [Note] [Entrypoint]: Temporary server started.
mysql-1  | '/var/lib/mysql/mysql.sock' -> '/var/run/mysqld/mysqld.sock'
mysql-1  | Warning: Unable to load '/usr/share/zoneinfo/iso3166.tab' as time zone. Skipping it.
mysql-1  | Warning: Unable to load '/usr/share/zoneinfo/leapseconds' as time zone. Skipping it.



mysql-1  | 2023-06-18T03:57:10.541213Z 0 [Note] InnoDB: page_cleaner: 1000ms intended loop took 13681ms. The settings might not be optimal. (flushed=200 and evicted=0, during the time.)
mysql-1  | Warning: Unable to load '/usr/share/zoneinfo/tzdata.zi' as time zone. Skipping it.
mysql-1  | Warning: Unable to load '/usr/share/zoneinfo/zone.tab' as time zone. Skipping it.
mysql-1  | Warning: Unable to load '/usr/share/zoneinfo/zone1970.tab' as time zone. Skipping it.
mysql-1  | 
mysql-1  | 2023-06-18 03:57:11+00:00 [Note] [Entrypoint]: Stopping temporary server
mysql-1  | 2023-06-18T03:57:11.153667Z 0 [Note] Giving 0 client threads a chance to die gracefully
mysql-1  | 2023-06-18T03:57:11.153730Z 0 [Note] Shutting down slave threads
mysql-1  | 2023-06-18T03:57:11.153749Z 0 [Note] Forcefully disconnecting 0 remaining clients
mysql-1  | 2023-06-18T03:57:11.153765Z 0 [Note] Event Scheduler: Purging the queue. 0 events
mysql-1  | 2023-06-18T03:57:11.153960Z 0 [Note] Binlog end
mysql-1  | 2023-06-18T03:57:11.158211Z 0 [Note] Shutting down plugin 'ngram'
mysql-1  | 2023-06-18T03:57:11.158260Z 0 [Note] Shutting down plugin 'partition'
mysql-1  | 2023-06-18T03:57:11.158271Z 0 [Note] Shutting down plugin 'BLACKHOLE'
mysql-1  | 2023-06-18T03:57:11.158281Z 0 [Note] Shutting down plugin 'ARCHIVE'
mysql-1  | 2023-06-18T03:57:11.158289Z 0 [Note] Shutting down plugin 'PERFORMANCE_SCHEMA'
mysql-1  | 2023-06-18T03:57:11.158323Z 0 [Note] Shutting down plugin 'MRG_MYISAM'
mysql-1  | 2023-06-18T03:57:11.158333Z 0 [Note] Shutting down plugin 'MyISAM'
mysql-1  | 2023-06-18T03:57:11.158347Z 0 [Note] Shutting down plugin 'INNODB_SYS_VIRTUAL'
mysql-1  | 2023-06-18T03:57:11.158356Z 0 [Note] Shutting down plugin 'INNODB_SYS_DATAFILES'
mysql-1  | 2023-06-18T03:57:11.158364Z 0 [Note] Shutting down plugin 'INNODB_SYS_TABLESPACES'
mysql-1  | 2023-06-18T03:57:11.158374Z 0 [Note] Shutting down plugin 'INNODB_SYS_FOREIGN_COLS'
mysql-1  | 2023-06-18T03:57:11.158386Z 0 [Note] Shutting down plugin 'INNODB_SYS_FOREIGN'
mysql-1  | 2023-06-18T03:57:11.158395Z 0 [Note] Shutting down plugin 'INNODB_SYS_FIELDS'
mysql-1  | 2023-06-18T03:57:11.158404Z 0 [Note] Shutting down plugin 'INNODB_SYS_COLUMNS'
mysql-1  | 2023-06-18T03:57:11.158415Z 0 [Note] Shutting down plugin 'INNODB_SYS_INDEXES'
mysql-1  | 2023-06-18T03:57:11.158423Z 0 [Note] Shutting down plugin 'INNODB_SYS_TABLESTATS'
mysql-1  | 2023-06-18T03:57:11.158433Z 0 [Note] Shutting down plugin 'INNODB_SYS_TABLES'
mysql-1  | 2023-06-18T03:57:11.158442Z 0 [Note] Shutting down plugin 'INNODB_FT_INDEX_TABLE'
mysql-1  | 2023-06-18T03:57:11.158450Z 0 [Note] Shutting down plugin 'INNODB_FT_INDEX_CACHE'
mysql-1  | 2023-06-18T03:57:11.158459Z 0 [Note] Shutting down plugin 'INNODB_FT_CONFIG'
mysql-1  | 2023-06-18T03:57:11.158470Z 0 [Note] Shutting down plugin 'INNODB_FT_BEING_DELETED'
mysql-1  | 2023-06-18T03:57:11.158478Z 0 [Note] Shutting down plugin 'INNODB_FT_DELETED'
mysql-1  | 2023-06-18T03:57:11.158488Z 0 [Note] Shutting down plugin 'INNODB_FT_DEFAULT_STOPWORD'
mysql-1  | 2023-06-18T03:57:11.158500Z 0 [Note] Shutting down plugin 'INNODB_METRICS'
mysql-1  | 2023-06-18T03:57:11.158508Z 0 [Note] Shutting down plugin 'INNODB_TEMP_TABLE_INFO'
mysql-1  | 2023-06-18T03:57:11.158515Z 0 [Note] Shutting down plugin 'INNODB_BUFFER_POOL_STATS'
mysql-1  | 2023-06-18T03:57:11.158525Z 0 [Note] Shutting down plugin 'INNODB_BUFFER_PAGE_LRU'
mysql-1  | 2023-06-18T03:57:11.158534Z 0 [Note] Shutting down plugin 'INNODB_BUFFER_PAGE'
mysql-1  | 2023-06-18T03:57:11.158542Z 0 [Note] Shutting down plugin 'INNODB_CMP_PER_INDEX_RESET'
mysql-1  | 2023-06-18T03:57:11.158553Z 0 [Note] Shutting down plugin 'INNODB_CMP_PER_INDEX'
mysql-1  | 2023-06-18T03:57:11.158563Z 0 [Note] Shutting down plugin 'INNODB_CMPMEM_RESET'
mysql-1  | 2023-06-18T03:57:11.158573Z 0 [Note] Shutting down plugin 'INNODB_CMPMEM'
mysql-1  | 2023-06-18T03:57:11.158585Z 0 [Note] Shutting down plugin 'INNODB_CMP_RESET'
mysql-1  | 2023-06-18T03:57:11.158593Z 0 [Note] Shutting down plugin 'INNODB_CMP'
mysql-1  | 2023-06-18T03:57:11.158605Z 0 [Note] Shutting down plugin 'INNODB_LOCK_WAITS'
mysql-1  | 2023-06-18T03:57:11.158613Z 0 [Note] Shutting down plugin 'INNODB_LOCKS'
mysql-1  | 2023-06-18T03:57:11.158621Z 0 [Note] Shutting down plugin 'INNODB_TRX'
mysql-1  | 2023-06-18T03:57:11.158630Z 0 [Note] Shutting down plugin 'InnoDB'
mysql-1  | 2023-06-18T03:57:11.158838Z 0 [Note] InnoDB: FTS optimize thread exiting.
mysql-1  | 2023-06-18T03:57:11.159636Z 0 [Note] InnoDB: Starting shutdown...
mysql-1  | 2023-06-18T03:57:11.264145Z 0 [Note] InnoDB: Dumping buffer pool(s) to /var/lib/mysql/ib_buffer_pool
mysql-1  | 2023-06-18T03:57:11.279738Z 0 [Note] InnoDB: Buffer pool(s) dump completed at 230618  3:57:11
mysql-1  | 2023-06-18T03:57:17.023058Z 0 [Note] InnoDB: Shutdown completed; log sequence number 12141930
mysql-1  | 2023-06-18T03:57:17.029870Z 0 [Note] InnoDB: Removed temporary tablespace data file: "ibtmp1"
mysql-1  | 2023-06-18T03:57:17.030144Z 0 [Note] Shutting down plugin 'MEMORY'
mysql-1  | 2023-06-18T03:57:17.030166Z 0 [Note] Shutting down plugin 'CSV'
mysql-1  | 2023-06-18T03:57:17.030187Z 0 [Note] Shutting down plugin 'sha256_password'
mysql-1  | 2023-06-18T03:57:17.030199Z 0 [Note] Shutting down plugin 'mysql_native_password'
mysql-1  | 2023-06-18T03:57:17.030397Z 0 [Note] Shutting down plugin 'binlog'
mysql-1  | 2023-06-18T03:57:17.034256Z 0 [Note] mysqld: Shutdown complete
mysql-1  | 
mysql-1  | 2023-06-18 03:57:17+00:00 [Note] [Entrypoint]: Temporary server stopped
mysql-1  | 
mysql-1  | 2023-06-18 03:57:17+00:00 [Note] [Entrypoint]: MySQL init process done. Ready for start up.
mysql-1  | 
mysql-1  | 2023-06-18T03:57:17.353858Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
mysql-1  | 2023-06-18T03:57:17.371827Z 0 [Note] mysqld (mysqld 5.7.39) starting as process 1 ...

다음번부터는 정상적으로 run 할 수 있다.

$ docker-compose up mysql
profile
coder,maker,custom

0개의 댓글