$ docker run -d \
--name mysql-container \
-v ${PWD}/mysql-data:/var/lib/mysql \
-e MYSQL_ROOT_PASSWORD=1q2w3e4r \
-e MYSQL_DATABASE=school \
-e LANG=ko_KR.UTF-8 \
-p 3306:3306 \
mysql:8.0.32 \
--character-set-server=utf8mb4 \
--collation-server=utf8mb4_unicode_ci
$ docker images
$ docker ps -a
$ docker logs -f mysql-container
$ docker exec -it mysql-container bash
bash-4.4# mysql -h localhost -u root -p school
Enter password:
mysql> SHOW DATABASES;
+--------------------+
| Database |
+--------------------+
| school |
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
5 rows in set (0.00 sec)
mysql> USE school;
Database changed
mysql> CREATE TABLE friends(
-> friend_id INT NOT NULL AUTO_INCREMENT,
-> first_name VARCHAR(30) NOT NULL,
-> last_name VARCHAR(30) NOT NULL,
-> cell_phone VARCHAR(15),
-> age INT DEFAULT NULL,
-> PRIMARY KEY (friend_id)
-> );
Query OK, 0 rows affected (0.04 sec)
mysql> SHOW TABLES;
+------------------+
| Tables_in_test |
+------------------+
| friends |
+------------------+
1 row in set (0.01 sec)
-e LANG=ko_KR.UTF-8 https://stackoverflow.com/a/66792543
$ docker run -d \
--name mysql-container \
-v ${PWD}/mysql-data:/var/lib/mysql \
-e MYSQL_ROOT_PASSWORD=1q2w3e4r \
-e MYSQL_DATABASE=school \
-p 3306:3306 \
mysql:8.0.32
mysql> status
--------------
mysql Ver 8.0.32 for Linux on aarch64 (MySQL Community Server - GPL)
Connection id: 8
Current database: school
Current user: root@localhost
SSL: Not in use
Current pager: stdout
Using outfile: ''
Using delimiter: ;
Server version: 8.0.32 MySQL Community Server - GPL
Protocol version: 10
Connection: Localhost via UNIX socket
Server characterset: utf8mb4
Db characterset: utf8mb4
Client characterset: latin1
Conn. characterset: latin1
UNIX socket: /var/run/mysqld/mysqld.sock
Binary data as: Hexadecimal
Uptime: 5 sec
Threads: 2 Questions: 7 Slow queries: 0 Opens: 139 Flush tables: 3 Open tables: 58 Queries per second avg: 1.400
--------------
$ docker run -d \
--name mysql-container \
-v ${PWD}/mysql-data:/var/lib/mysql \
-e MYSQL_ROOT_PASSWORD=1q2w3e4r \
-e MYSQL_DATABASE=school \
-e LANG=ko_KR.UTF-8 \
-p 3306:3306 \
mysql:8.0.32 \
--character-set-server=utf8mb4 \
--collation-server=utf8mb4_unicode_ci
mysql> status
--------------
mysql Ver 8.0.32 for Linux on aarch64 (MySQL Community Server - GPL)
Connection id: 9
Current database: school
Current user: root@localhost
SSL: Not in use
Current pager: stdout
Using outfile: ''
Using delimiter: ;
Server version: 8.0.32 MySQL Community Server - GPL
Protocol version: 10
Connection: Localhost via UNIX socket
Server characterset: utf8mb4
Db characterset: utf8mb4
Client characterset: utf8mb4
Conn. characterset: utf8mb4
UNIX socket: /var/run/mysqld/mysqld.sock
Binary data as: Hexadecimal
Uptime: 24 sec
Threads: 2 Questions: 7 Slow queries: 0 Opens: 139 Flush tables: 3 Open tables: 58 Queries per second avg: 0.291
--------------
참고)