이 문서는 CentOS 7에서 Mysql 설치에 대한 가이드를 제공한다.
설치 환경
OS : CentOS 7 64bit
DB : Mysql 5.6.35
설치 화면
저장소 추가
아래 명령어로 repository 추가를 한다.
rpm -ivh http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
MySQL 패키지 설치
yum으로 MySQL 패키지를 설치한다.
yum install -y mysql-server
MySQL 실행
아래 명령어로 mysql를 실행 한다.
systemctl start mysqld
MySQL 보안 설정
아래 명령어로 Mysql 보안 설정을 한다.
- root 비밀번호를 설정 할 것인가?
- root 비밀번호 가 맞는가?
- 다른 유저를 삭제 할 것인가?
- root의 원격 접속을 허용 할 것인가?
- test database를 삭제 할 것인가?
- privileges 테이블을 재 시작 할 것인가?
/usr/bin/mysql_secure_installation Enter current password for root (enter for none): Set root password? [Y/n] Y Remove anonymous users? [Y/n] Y Disallow root login remotely? [Y/n] Y Remove test database and access to it? [Y/n] Y Reload privilege tables now? [Y/n] Y
MySQL 실행
아래 명령어로 Mysql를 실행한다.
mysql -u root -p mysqlEnter password: Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 18 Server version: 5.6.35 MySQL Community Server (GPL) Copyright (c) 2000, 2016, 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 데이터베이스 생성
아래 명령어로 새로운 Database 생성 할 수 있다.
create database DBname default character set utf8;
MySQL 유저 생성
아래 명령어로 새로운 유저를 생성 할 수 있다.
- '유저아이디'@'%' 외부 접속만 가능한 유저 생성
- '유저아이디'@'localhost' 로컬 접속만 가능한 유저 생성
create user '유저아이디'@'%'identified by '비밀번호'; create user '유저아이디'@'localhost'identified by '비밀번호';
MySQL 권한 부여
아래 명령어로 권한을 부여 할 수 있다.
- grant all privileges on *.* to '아이디'@'%' 유저에게 모든 권한 부여
- grant all privileges on DB이름.* to '아이디'@'%' 유저에게 특정DB를 관리 할 수 있는 권한 부여
grant all privileges on *.* to '아이디'@'%'; grant all privileges on DB이름.* to '아이디'@'%';
MySQL Database 삭제
아래 명령어로 Database를 삭제 할 수 있다.
drop database DB이름;
MySQL User 삭제
아래 명령어로 User를 삭제 할 수 있다.
- '유저아이디'@'%' 외부 접속 유저 삭제
- '유저아이디'@'localhost' 로컬 접속 유저 생성
drop user '유저아이디'@'%'; drop user '유저아이디'@'localhost';
1 개의 댓글
익명