[DB] DB 설치 및 사용법

jungeundelilahLEE·2021년 1월 12일
0

DB(DataBase)

목록 보기
3/8

goal

  • 설치 후 사용법을 익힌다

MySQL 설치

macOS
Homebrew라는 패키지 매니저를 먼저 설치합니다.

Homebrew를 이용한 설치
$ brew install mysql
$ brew info mysql

Ubuntu Linux
apt-get 이라는 패키지 매니저를 이용합니다. 우분투 리눅스를 설치하면 사전에 설치되어 있습니다.

apt-get을 이용한 설치
$ sudo apt-get update
$ sudo apt-get install mysql-server

MySQL 서비스 시작

설치 후에 MySQL 서비스를 실행해야 MySQL을 사용할 수 있습니다.

macOS
$ brew services start mysql

Ubuntu Linux
$ sudo systemctl start mysql

MySQL 접속

아래의 명령어로 MySQL에 접속할 수 있습니다. 오류가 발생하거나, 존재하지 않는 명령어라는 결과가 나온다면, 설치에 문제가 있거나, 혹은 MySQL이 실행되지 않은 상태입니다.

mysql -u(계정 접근) [계정명] -p(비밀번호 입력)

$ mysql -u root -p 입력 후, password를 입력하면, 다음과 같이 나오면 성공!

Enter password: 12
Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 19 Server version: 8.0.22-0ubuntu0.20.04.3 (Ubuntu)
Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
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>

여러분이 설치했을 때 따로 계정을 추가하거나 비밀번호를 설정하지 않으셨다면 초기 MySQL의 기본 root의 암호는 비어 있으므로 "ENTER"를 눌러주세요.
이 단계에서 로그인이 되지 않는 경우 검색을 통해 문제를 해결해 보세요

mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '[yourPassword]';

SQL GUI Support Tool

데이터베이스에 접속하는 것을 터미널 환경(command line interface)이 아닌 이를 보조해주는 툴(Graphic User Interface)를 이용해서 데이터베이스에 접속할 수 있습니다. SQL을 입력하여 실행하거나, 테이블 정보를 볼 수 있도록 지원합니다. 아래의 대표적인 GUI Support Tool 중 원하시는 것을 선택하고, 이를 활용해보세요.

  • MySQL Workbench
  • Sequel Pro (OSX 전용)
  • Table Plus
  • DBeaver
  • DataGrip
profile
delilah's journey

0개의 댓글