MySQL Settings

SYiee·2025년 2월 12일
0

기타

목록 보기
4/5

Install

brew install mysql
brew services start mysql

Start

mysql -u root -p #시작하는 명령어

Commands

Create New DB

CREATE DATABASE database_name;
SHOW DATABASES; # 목록 보기
USE database_name; # 데이터베이스 선택

Create user and Grant

#사용자 생성
CREATE USER 'username'@'localhost' IDENTIFIED BY 'password';

# 권한 부여
GRANT ALL PRIVILEGES ON database_name.* TO 'username'@'localhost';
# 권한 적용
FLUSH PRIVILEGES;

Create Table

CREATE TABLE table_name (
    id INT AUTO_INCREMENT PRIMARY KEY,
    name VARCHAR(100),
    age INT
);

Show DB

show tables;

mysql> SHOW tables;
+----------------+
| Tables_in_test |
+----------------+
| balanceHistory |
+----------------+
1 row in set (0.00 sec)

---------------------------------------------------------------------------
DESCRIBE balanceHistory;

mysql> DESCRIBE balanceHistory;
+----------------+--------+------+-----+---------+----------------+
| Field          | Type   | Null | Key | Default | Extra          |
+----------------+--------+------+-----+---------+----------------+
| id             | int    | NO   | PRI | NULL    | auto_increment |
| BinanceBalance | double | NO   |     | NULL    |                |
| createdAt      | date   | NO   |     | NULL    |                |
+----------------+--------+------+-----+---------+----------------+
3 rows in set (0.00 sec)

---------------------------------------------------------------------------
mysql> SELECT * FROM balanceHistory;
+----+----------------+------------+
| id | BinanceBalance | createdAt  |
+----+----------------+------------+
|  2 |           36.7 | 2025-01-02 |
|  3 |          38.64 | 2025-01-01 |
|  4 |             40 | 2024-12-31 |
|  5 |    33.97955212 | 2025-01-03 |
profile
게임 개발자

0개의 댓글

관련 채용 정보