MySQL
MySQL์ ๋ฐ์ดํฐ๋ฒ ์ด์ค ์ํํธ์จ์ด์ ๋๋ค. ์ผ๋ฐ์ ์ผ๋ก ๋ฐ์ดํฐ๋ฅผ ์ถ๊ฐํ๊ฑฐ๋ ๊ฒ์, ์ถ์ถํ๋ ๊ธฐ๋ฅ์ ๋ชจ๋ ํฌํจํด์ ๋ฐ์ดํฐ๋ฒ ์ด์ค๋ผ๊ณ ๋ถ๋ฆ ๋๋ค.
MySQL์ ์ธ๊ณ์์ ๊ฐ์ฅ ๋ง์ด ์ฐ๋ ์คํ ์์ค์ ๊ด๊ณํ ๋ฐ์ดํฐ๋ฒ ์ด์ค ๊ด๋ฆฌ์์คํ
(RDBMS)์
๋๋ค.
MySQL์ PHP ์คํฌ๋ฆฝํธ ์ธ์ด์ ์ํธ ์ฐ๋์ด ์ ๋๋ฉด์ ์คํ์์ค๋ฅผ ๊ฐ๋ฐ๋ ๋ฌด๋ฃ ํ๋ก๊ทธ๋จ์
๋๋ค.
๊ทธ๋์ ํํ์ด์ง๋ ์ผํ๋ชฐ(์๋ํ๋ ์ค, Cafe24, ์ ๋ก๋ณด๋ ๊ทธ๋๋ณด๋)๋ฑ ์ผ๋ฐ์ ์ผ๋ก ์น ๊ฐ๋ฐ์ ๋๋ฆฌ ์ฌ์ฉํ๊ณ ์์ต๋๋ค.
MySQL ์ค์น
http://www.mamp.info/en/downlads/
MySQL ์คํ
๋ก๊ทธ์ธ : mysql -uroot -proot
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4
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 -uroot -proot
webstoryboyhwang@Webstoryboyui-MacBookPro bin % ./mysql -uroot -proot
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 188
Server version: 5.7.34 MySQL Community Server (GPL)
Copyright (c) 2000, 2021, 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> create database sample02;
Query OK, 1 row affected (0.00 sec)
๋ฐ์ดํฐ๋ฒ ์ด์ค ๋ณด๊ธฐ
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sample01 |
| sample02 |
| sys |
+--------------------+
6 rows in set (0.00 sec)
๋ฐ์ดํฐ๋ฒ ์ด์ค ์ฌ์ฉ
mysql> use sample01;
Database changed
๋ฐ์ดํฐ๋ฒ ์ด์ค ์ญ์
mysql> drop database sample02;
Query OK, 0 rows affected (0.03 sec)
ํ ์ด๋ธ
ํ ์ด๋ธ ๋ง๋ค๊ธฐ
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,
regTime int(20) NOT NULL,
PRIMARY KEY (myMemberID)
) charset=utf8;
ํ ์ด๋ธ ์ ์ฒด๋ณด๊ธฐ
mysql> show tables;
+--------------------+
| Tables_in_sample01 |
+--------------------+
| member |
+--------------------+
1 row in set (0.00 sec)
ํ ์ด๋ธ ๋ณด๊ธฐ
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 | |
| regTime | int(20) | NO | | NULL | |
+------------+------------------+------+-----+---------+----------------+
6 rows in set (0.01 sec)
ํ ์ด๋ธ ์ญ์
mysql> drop table member;
Query OK, 0 rows affected (0.01 sec)
ํ ์ด๋ธ ๋ณต์ฌ
ํ ์ด๋ธ ๋ฐ์ดํฐ
ํ ์ด๋ธ ์ ๋ ฅํ๊ธฐ
INSERT INTO member(youEmail, youName, youPass, youBirth, regTime) VALUES('***@gmail.com', 'ํฉ**', '1234', '19******', '1234567')
INSERT INTO member(youEmail, youName, youPass, youBirth, regTime) VALUES('***@naver.com', '๊น**', '1234', '19******', '04')
INSERT INTO member(youEmail, youName, youPass, youBirth, regTime) VALUES('***@naver.com','๊ถ**','1234','19******','1234567');
INSERT INTO member(youEmail, youName, youPass, youBirth, regTime) VALUES('***@gmail.com', '๋ฌธ**', '1234', '19******', '1234567');
INSERT INTO member(youEmail, youName, youPass, youBirth, regTime) VALUES('***@gmail.com','์ด**','1234','19******','1234567');
INSERT INTO member(youEmail, youName, youPass, youBirth, regTime) VALUES('***@gmail.com','๊ถ**','1234','19******','1234567');
INSERT INTO member(youEmail, youName, youPass, youBirth, regTime) VALUES('***@gmail.com','์ **','1234','19******','1234567');
INSERT INTO member(youEmail, youName, youPass, youBirth, regTime) VALUES('***@naver.com','๊น**','1234','19******','1234567')
INSERT INTO member(youEmail, youName, youPass, youBirth, regTime) VALUES('***@gmail.com', '๊น**', '1234', '20******','1234567');
INSERT INTO member(youEmail, youName, youPass, youBirth, regTime) VALUES('***@naver.com','์ด**','1234','19******','1234567')
INSERT INTO member(youEmail, youName, youPass, youBirth, regTime) VALUES('***3@naver.com', '๊น**', '1234', '19******', '1234567');
ํ ์ด๋ธ ๋ถ๋ฌ์ค๊ธฐ
์ ์ฒด ๋ฐ์ดํฐ ๋ถ๋ฌ์ค๊ธฐ
mysql> SELECT * FROM member;
+------------+--------------------------+---------+---------+----------+----------+
| myMemberID | youEmail | youName | youPass | youBirth | regTime |
+------------+--------------------------+---------+---------+----------+----------+
| 1 | ****@gmail.com | ํฉ** | 1234 | 19****** | 1234567 |
| 2 | ****@naver.com | ๋ฐ** | 1234 | 19****** | 1234567 |
| 3 | ****@naver.com | ๊น** | 1234 | 19****** | 4 |
| 4 | ****@gmail.com | ๊ฐ** | 1234 | 19****** | 1234567 |
| 5 | ****@gmail.com | ๋ฐ** | 1234 | 19****** | 1234567 |
| 6 | ****@gmail.com | ์ด** | 1234 | 19****** | 1234567 |
| 7 | ****@gmail.com | ๊น** | 1234 | 19****** | 1234567 |
| 8 | ****@naver.com | ์ฌ** | 1234 | 22****** | 12324567 |
| 9 | ****@naver.com | ์ต** | 3950 | 20****** | 1234567 |
| 10 | ****@gmail.com | ์ ** | 1234 | 19****** | 1234567 |
| 11 | ****@gmail.com | ๊ถ** | 1234 | 19****** | 1234567 |
| 12 | ****@gmail.com | ๋ฌธ** | 1234 | 19****** | 1234567 |
| 13 | ****@naver.com | ๊ถ** | 1234 | 19****** | 1234567 |
| 14 | ****@naver.com | ๊น** | 1234 | 19****** | 4 |
| 15 | ****@gmail.com | ์ด** | 1234 | 19****** | 1234567 |
| 16 | ****@naver.com | ๊น** | 1234 | 19****** | 1234567 |
| 17 | ****@naver.com | ์ก** | 1234 | 19****** | 1234567 |
| 18 | ****@naver.com | ๊น** | 1234 | 19****** | 1234567 |
| 19 | ****@naver.com | ๊น** | 1234 | 19****** | 1234567 |
| 20 | ****@naver.com | ์ ** | 1234 | 19****** | 1234567 |
| 21 | ****@gmail.com | ๊น** | 1234 | 20****** | 1234567 |
| 22 | ****@naver.com | ์ด** | 1234 | 19****** | 1234567 |
| 23 | ****@naver.com | ๊น** | 1234 | 19****** | 1234567 |
+------------+--------------------------+---------+---------+----------+----------+
23 rows in set (0.00 sec)
myMemberID๊ฐ 6๋ฒ์ธ ๊ฒฝ์ฐ
mysql> SELECT * FROM member WHERE myMemberID = 6;
+------------+----------------------+---------+---------+----------+---------+
| myMemberID | youEmail | youName | youPass | youBirth | regTime |
+------------+----------------------+---------+---------+----------+---------+
| 6 | **********@gmail.com | ์ด** | 1234 | 19****** | 1234567 |
+------------+----------------------+---------+---------+----------+---------+
1 row in set (0.01 sec)
Email ์ค์ naver ํ ์คํธ๋ฅผ ํฌํจํ๊ณ ์๋ ๊ฒฝ์ฐ
mysql> SELECT * FROM member WHERE youEmail LIKE '%naver%';
+------------+------------------------+---------+---------+----------+----------+
| myMemberID | youEmail | youName | youPass | youBirth | regTime |
+------------+------------------------+---------+---------+----------+----------+
| 2 | ****@naver.com | ๋ฐ** | 1234 | 19****** | 1234567 |
| 3 | ****@naver.com | ๊น** | 1234 | 19****** | 4 |
| 8 | ****@naver.com | ์ฌ** | 1234 | 22****** | 12324567 |
| 9 | ****@naver.com | ์ต** | 3950 | 20****** | 1234567 |
| 13 | ****@naver.com | ๊ถ** | 1234 | 19****** | 1234567 |
| 14 | ****@naver.com | ๊น** | 1234 | 19****** | 4 |
| 16 | ****@naver.com | ๊น** | 1234 | 19****** | 1234567 |
| 17 | ****@naver.com | ์ก** | 1234 | 19****** | 1234567 |
| 18 | ****@naver.com | ๊น** | 1234 | 19****** | 1234567 |
| 19 | ****@naver.com | ๊น** | 1234 | 19****** | 1234567 |
| 20 | ****@naver.com | ์ ** | 1234 | 19****** | 1234567 |
| 22 | ****@naver.com | ์ด** | 1234 | 19****** | 1234567 |
| 23 | ****@naver.com | ๊น** | 1234 | 19****** | 1234567 |
+------------+------------------------+---------+---------+----------+----------+
13 rows in set (0.00 sec)
ํ ์ด๋ธ ์์ ํ๊ธฐ
ํ ์ด๋ธ ์ญ์ ํ๊ธฐ
'์๋ฐ์คํฌ๋ฆฝํธ' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
์ค๋ต๋ ธํธ (1) | 2022.10.04 |
---|---|
mouseenter / mouseover ์ ์ฐจ์ด (2) | 2022.09.06 |
์ ์ด์ฟผ๋ฆฌ ์คํ์ผ ๊ด๋ จ ๋ฉ์๋ (2) | 2022.09.06 |
์ ์ด์ฟผ๋ฆฌ ์คํ์ผ ๊ด๋ จ ๋ฉ์๋ (2) | 2022.09.05 |
์ ์ด์ฟผ๋ฆฌ ์์ฑ ๊ด๋ จ ๋ฉ์๋ (2) | 2022.09.05 |
๋๊ธ