[SQL] 11~12강 AWS 연결

JONGYOON JEON·2024년 2월 7일
0

SQL

목록 보기
3/13

cmd에서 mysql 접속안되는 환경변수 오류

기존 mysql prompt 에서 실습을 게속 해왔더니, aws 외부 연결을 하려하니 오류가 발생했다.

환경변수 path 지정이 안되서 그런 건데
아래 링크를 참고하면 금방할 수 있다!

https://wrkbr.tistory.com/526

권한 주기 복습

mysql> show grants for 'zero'@"%";
+----------------------------------------------------+
| Grants for zero@% |
+----------------------------------------------------+
| GRANT USAGE ON . TO zero@% |
| GRANT ALL PRIVILEGES ON zerobase.* TO zero@% |
+----------------------------------------------------+
2 rows in set (0.15 sec)

mysql> grants all on zerobase.* to 'zero'@'%';

폴더 만들고 VScode로 실행

  1. cmd 킴
  2. mkdir sql_ws
  3. cd "C:\Users\jongyoon\sql_ws"
  4. code .

VScode에서 SQL 함수 만들고 외부에서 실행하기

C:\Users\jongyoon\sql_ws>mysql -u root -p zerobase < test02.sql
Enter password: ***

C:\Users\jongyoon\sql_ws>mysql -u root -p zerobase
Enter password: ****

Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 23
Server version: 8.3.0 MySQL Community Server - GPL

Copyright (c) 2000, 2024, 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> show tables;
+--------------------+
| Tables_in_zerobase |
+--------------------+
| celeb |
| crime_status |
| police_station |
| snl_show |
| test1 |
| test2 |
+--------------------+
6 rows in set (0.00 sec)

mysql> desc crime_status
-> ;
+----------------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------------+-------------+------+-----+---------+-------+
| year | year | YES | | NULL | |
| police_station | varchar(8) | YES | | NULL | |
| crime_type | varchar(16) | YES | | NULL | |
| status_type | char(2) | YES | | NULL | |
| case_number | int | YES | | NULL | |
+----------------+-------------+------+-----+---------+-------+
5 rows in set (0.00 sec)

VScode terminal 에서 바로 하기 오류

PS C:\Users\jongyoon\sql_ws> mysql -u root -p zerobase < test02.sql
위치 줄:1 문자:27

  • mysql -u root -p zerobase < test02.sql
  •                       ~
    '<' 연산자는 나중에 사용하도록 예약되어 있습니다.
    + CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : RedirectionNotSupported

껏다키니 된다..

dump backup 오류

PS C:\Users\jongyoon\sql_ws> mysqldump -u root -p zerobase celeb --default-character-set utf8mb4 > back07.sql
Enter password: ****
PS C:\Users\jongyoon\sql_ws> mysql -h "database-1.cfs2ce6vbi.ap-southeast-2.rds.amazonaws.com" -P 3306 -u admin -p
Enter password: ****
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 76
Server version: 8.0.35 Source distribution

Copyright (c) 2000, 2024, 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> source back07.sql
ERROR:
ASCII '\0' appeared in the statement, but this is not allowed unless option --binary-mode is enabled and mysql is run in non-interactive mode. Set --binary-mode to 1 if ASCII '\0' is expected. Query: '?-'.
Bye
PS C:\Users\jongyoon\sql_ws>

utf8mb4 로 백업 덤프했는데도 게속 ASCI 오류가 뜬다 ...
해결 못했음 ㅠㅠ

--set-gtid-purged=OFF

--set-gtid-purged=OFF 옵션은 mysqldump 명령을 사용하여 MySQL 데이터베이스를 백업할 때 Global Transaction Identifier(GTID) 정보를 백업 파일에 포함하지 않도록 하는 옵션입니다.

GTID는 MySQL 서버에 의해 자동으로 생성되는 고유한 트랜잭션 식별자로, 복제나 장애 복구 등에서 트랜잭션을 식별하거나 추적하는 데 사용됩니다.

mysqldump 명령에 --set-gtid-purged=OFF 옵션을 추가하면, 백업 파일에 SET @@GLOBAL.gtid_purged 문이 포함되지 않습니다. 이는 GTID가 활성화된 복제 설정에서 중요할 수 있습니다.

옵션의 기본값은 AUTO이며, 이 경우 mysqldump는 GTID가 활성화되고 --all-databases 또는 --databases 옵션이 사용된 경우에만 SET @@GLOBAL.gtid_purged 문을 추가합니다.

따라서 --set-gtid-purged=OFF 옵션을 사용하는 경우, 백업 파일을 사용하여 데이터베이스를 복원하더라도 GTID 정보는 복원되지 않습니다. 이는 특정 상황에서 원하는 결과를 얻기 위해 필요할 수 있습니다.

profile
효율적인 걸 좋아해요

0개의 댓글