Database
[MySQL] 접속
lv.COCO
2023. 3. 16. 14:53
1. MySQL 활성화 & 상태 확인
[root@kim ~]# systemctl enable mysqld && systemctl start mysqld && systemctl status mysqld
● mysqld.service - MySQL Server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
Active: active (running) since 목 2023-03-16 14:30:58 KST; 1min 32s ago
Docs: man:mysqld(8)
http://dev.mysql.com/doc/refman/en/using-systemd.html
Main PID: 1640 (mysqld)
Status: "Server is operational"
CGroup: /system.slice/mysqld.service
└─1640 /usr/sbin/mysqld
3월 16 14:30:56 kim systemd[1]: Starting MySQL Server...
3월 16 14:30:58 kim systemd[1]: Started MySQL Server.
2. root 계정으로 MySQL 접속
[root@kim ~]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.32 MySQL Community Server - GPL
Copyright (c) 2000, 2023, 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.
3. 계정 생성을 위해 기본 DB에 접속
mysql> use mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
+ 처음에 대문자로 입력했더니 오류 계속남,, 검색하니까 DB 생성 어쩌꾸 bin 하위 폴더 어쩌구 하는데
ERROR 1049 (42000): Unknown database 'MYSQL' |
mysql> USE MYSQL;
mysql > show databases;
해보면 소문자길래 혹시 하고 소문자로 입력해보니까 됨,,ㅠ
4. 계정 생성 & 권한부여
mysql> create user 'testuser' identified by '비밀번호';
Query OK, 0 rows affected (0.00 sec)
mysql> grant all privileges on *.* to 'testuser'@'%';
-- 권한 반영
mysql> flush privileges;
※ %는 모든 권한