티스토리 뷰

(base) PS C:\Users\AIA\MsaProject> docker ps
CONTAINER ID   IMAGE               COMMAND                  CREATED      STATUS             PORTS                               NAMES
ad446d26f865   fastapiserver-api   "uvicorn app.main:ap…"   7 days ago   Up About an hour   0.0.0.0:8000->8000/tcp              api
2b8685805bfe   fastapiserver-db    "docker-entrypoint.s…"   7 days ago   Up 3 hours         0.0.0.0:3306->3306/tcp, 33060/tcp   mydb
(base) PS C:\Users\AIA\MsaProject> docker exec -it 2b8685805bfe bash
bash-4.2# mysql -u root -p
mysql: [Warning] World-writable config file '/etc/mysql/conf.d/my.cnf' is ignored.
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 115
Server version: 5.7.40-log MySQL Community Server (GPL)

Copyright (c) 2000, 2022, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> use mydb;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> show tables;
+----------------+
| Tables_in_mydb |
+----------------+
| articles       |
| users          |
+----------------+
2 rows in set (0.00 sec)

mysql> alter table users modify token varchar(256);
Query OK, 0 rows affected (0.02 sec)
Records: 0  Duplicates: 0  Warnings: 0

mysql> desc users;
+-----------+--------------+------+-----+-------------------+-----------------------------+
| Field     | Type         | Null | Key | Default           | Extra                       |
+-----------+--------------+------+-----+-------------------+-----------------------------+
| created   | timestamp    | NO   |     | CURRENT_TIMESTAMP |                             |
| modified  | timestamp    | NO   |     | CURRENT_TIMESTAMP | on update CURRENT_TIMESTAMP |
| userid    | varchar(30)  | NO   | PRI | NULL              |                             |
| email     | varchar(50)  | NO   | UNI | NULL              |                             |
| password  | varchar(100) | NO   |     | NULL              |                             |
| username  | varchar(20)  | NO   |     | NULL              |                             |
| phone     | varchar(20)  | YES  |     | NULL              |                             |
| birth     | varchar(20)  | YES  |     | NULL              |                             |
| address   | varchar(100) | YES  |     | NULL              |                             |
| job       | varchar(20)  | YES  |     | NULL              |                             |
| interests | varchar(100) | YES  |     | NULL              |                             |
token     | varchar(256) | YES  |     | NULL              |                             |
+-----------+--------------+------+-----+-------------------+-----------------------------+
12 rows in set (0.00 sec)

 

이후 반드시 도커를 재시작해야 적용된다.

재시작 후 연결된 파이참에 가서 속성 변경까지 확인한다.

 

 

MySQL 테이블 속성 변경 참조 블로그

https://juyoung-1008.tistory.com/17

 

MySQL 컬럼명 변경, 컬럼 타입 변경, 컬럼 추가, 컬럼 삭제

계속 찾아보게 되서 정리해 봅니다. 컬럼명 변경 ALTER TABLE 테이블명 CHANGE 기존컬럼명 변경할컬럼명 컬럼타입; mysql> ALTER TABLE user CHANGE socre score int;컬럼 순서변경 ALTER TABLE 테이블명 MODIFY 순서변

juyoung-1008.tistory.com

 

댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/12   »
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31
글 보관함