Database/MySQL
MySQL 콘솔 접속 방법
기록하는 백앤드개발자
2024. 1. 18. 10:21
반응형
ㅁ 방법 요약
# root 로컬 접속
mysql -u root -p
# 호스트 접속(도메인)
mysql -h peterica.iptime.org -P 3307 -u {user} -p
# 호스트 Database 접속
mysql -h peterica.iptime.org -P 3307 -u {user} -p {database_name}
# 호스트 접속(ip)
mysql -h 127.0.0.1 -P 3307 -u {user} -p
ㅇ대문자 구분해야 주의!! -P는 대문자다.
ㅁ들어가며
사용자 비밀번호 바꾸려면 root로 들어가야 하는데, 맨날 까먹어서 정리해 놓음. docker로 만들어 놔서 docker -> 컨테이너 -> mysql cli로 접속해야 한다.
update...
[Mysql] brew mysql cli 설치 후 SQL 파일 실행하기, insert파일 실행
아... 예전에 위에서 과정 중에 접속 방법 정리해 놓은게 있었다....
기왕 이렇게 된거 root랑 원격 접속 방법 정리하고 요약본을 정리함.
ㅁ ROOT 로컬 접속 방법
# docker 접속
$ docker exec -it mysql_57 bash ✔ 7292 10:16:48
# mysql root 접속
root@ca4a4ca3ca82:/# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 13
Server version: 5.7.37 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> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| employees |
| mysql |
| northwind |
| performance_schema |
| sys |
| tuning |
+--------------------+
7 rows in set (0.01 sec)
mysql>
ㅁ 원격 접속 방법
# 문법
mysql -h {host} -P {port} -u {user} -p
# 실행
$ mysql -h peterica.iptime.org -P 3307 -u rcs -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 373
Server version: 5.7.37 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> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| rcs |
+--------------------+
2 rows in set (0.06 sec)
mysql>
ㅇ 접속을 위한 문법에 맞게 접속을 위한 host 정보와 port, User 정보를 확인하여 커멘드를 완성한다.
ㅇ show databases 명령어를 실행하여 database 정보를 확인하였다.
반응형