MySQL

MySQL이란?

Kim do hyun 2023. 3. 13. 22:14
728x90
반응형

MySQL은 오픈 소스 관계형 데이터베이스 관리 시스템(RDBMS)입니다.

MySQL은 다중 사용자, 다중 스레드 RDBMS로서, 데이터의 안정성과 보안성을 제공합니다.
MySQL은 대부분의 운영 체제에서 작동하며, 웹 애플리케이션 개발, 

데이터 분석, 빅 데이터, 클라우드 기반 애플리케이션 등에 많이 사용됩니다.

 

MySQL은 SQL(Structured Query Language)을 사용하여 데이터를 관리합니다. 
SQL은 데이터베이스에 저장된 데이터를 조작하기 위한 표준적인 언어로서, 

데이터를 검색, 삽입, 업데이트, 삭제하는데 사용됩니다. 

 

MySQL은 이러한 SQL 문을 이용하여 데이터를 쿼리하고, 데이터의 무결성을 유지하며, 데이터베이스를 관리합니다.
MySQL은 사용이 간편하며, 대용량 데이터베이스를 처리할 수 있는 고성능 기능을 제공합니다. 

 

또한, 오픈 소스로서, 다양한 개발자들이 지속적으로 개발 및 유지보수하고 있어, 

사용자들이 다양한 문제들을 해결할 수 있는 방법을 제공합니다.

 

MySQL은 PHP 스크립트 언어와 상호 연동이 잘 되면서 오픈소스로 개발된 무료 프로그램입니다.
그래서 홈페이지나 쇼핑몰(워드프레스, Cafe24, 그누보드, 제로보드)은 일반적으로 웹 개발에 널리 사용하고 있습니다.

 

 

 

MySQL 다운로드

다운로드

 

 

 

MySQL 실행

윈도우와 맥 동일하게 시작 화면에서 검색을 이용해 각각 아래의 방법으로 실행합니다.

윈도우 : cd MAMP/bin/mysql/bin
맥 : cd /Applications/MAMP/Library/bin

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 6
Server version: 5.7.24 MySQL Community Server (GPL)

Copyright (c) 2000, 2018, 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 -uroot -proot
맥 : ./mysql -uroot -proot

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 6
Server version: 5.7.24 MySQL Community Server (GPL)

Copyright (c) 2000, 2018, 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.

 

 

데이터베이스 

데이터베이스 보는법

명령어창에 show databases;를 입력합니다.

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
4 rows in set (0.02 sec)

데이터베이스  만들기

create database (데이터베이스 이름); 를 명령어창에 입력합니다. 괄호제외

mysql> create database sample01;
Query OK, 1 row affected (0.00 sec)

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sample01           |
| sys                |
+--------------------+
5 rows in set (0.00 sec)

데이터베이스 사용, 삭제

use (데이터베이스 이름);를 명렁어창에 입력합니다.괄호제외

mysql> use sample01;
Database changed

drop database (데이터베이스 이름);를 명렁어창에 입력합니다.괄호제외

mysql> drop database sample01;
Query OK, 0 rows affected (0.03 sec)

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
4 rows in set (0.00 sec)

 

 

테이블

테이블 만들기

명렁어창에 create table (테이블 이름);를 입력합니다.괄호제외

create table member (
    myMemberID int(10) unsigned auto_increment,
    youEmail varchar(40) NOT NULL,
    youName varchar(20) NOT NULL,
    youPass varchar(20) NOT NULL,
    youBirth int(20) NOT NULL,
    youAge int(5) NOT NULL,
    regTime int(20) NOT NULL,
    PRIMARY KEY (myMemberID)
) charset=utf8;

테이블 전체보기

명령어창에 show tables;를 입력합니다.

mysql> show tables;
+--------------------+
| Tables_in_sample01 |
+--------------------+
| member             |
+--------------------+
1 row in set (0.00 sec)

테이블 보기

desc (테이블 이름);를 명렁어창에 입력합니다.괄호제외

mysql> desc member;
+------------+------------------+------+-----+---------+----------------+
| Field      | Type             | Null | Key | Default | Extra          |
+------------+------------------+------+-----+---------+----------------+
| myMemberID | int(10) unsigned | NO   | PRI | NULL    | auto_increment |
| youEmail   | varchar(40)      | NO   |     | NULL    |                |
| youName    | varchar(20)      | NO   |     | NULL    |                |
| youPass    | varchar(20)      | NO   |     | NULL    |                |
| youBirth   | int(20)          | NO   |     | NULL    |                |
| youAge     | int(5)           | NO   |     | NULL    |                |
| regTime    | int(20)          | NO   |     | NULL    |                |
+------------+------------------+------+-----+---------+----------------+
7 rows in set (0.00 sec)

테이블 삭제

drop table (테이블 이름);를 명령어창에 입력합니다.괄호제외

mysql> drop table member;
Query OK, 0 rows affected (0.01 sec)

 

테이블 복사

아직 배우지 않음