상세 컨텐츠

본문 제목

[MySQL]Ubuntu 18.04 MySQL 8.0 설치 및 원격 계정 설정

WEB & Mobile

by mobile 2022. 10. 30. 14:11

본문

반응형
설치 OS : Ubuntu 18.04.6 LTS
설치 DB : mysql Ver 8.0.31 for Linux on x86_64 (MySQL Community Server - GPL)

 

1) MySQL8 APT Repository 다운로드 및 설치
// 다운로드
wget https://dev.mysql.com/get/mysql-apt-config_0.8.24-1_all.deb

 

Repository 버전은 아래 MySQL 사이트 하단에 보이는 버전을 추가하였다.

 

https://dev.mysql.com/downloads/repo/apt/

 

MySQL :: Download MySQL APT Repository

The MySQL APT repository provides a simple and convenient way to install and update MySQL products with the latest software packages using Apt. The MySQL APT repository provides MySQL packages for the following Linux distros: The MySQL APT repository inclu

dev.mysql.com

// 설치
sudo dpkg -i mysql-apt-config_0.8.24-1_all.deb

 

위의 명령을 실행하면 아래와 같은 프롬프트가 열리는데 확인을 클릭한다.

 

 

2) MySQL 8 설치
// 시스템 패키지 업데이트
sudo apt-get update

 

아래와 같이 repository가 추가되는 것을 확인할 수 있다.

 

 

MySQL 8 서버를 설치 합니다.

sudo apt-get install mysql-server

 

위의 명령어를 입력하면 아래와 같은 창이 뜨는데 root 계정에서 사용할 비밀번호를 입력한다.

 

 

다시 한번 입력한다.

 

 

암호를 입력한 후 암호 암호화 기능을 요청하고 권장하지만, 개발 테스트 서버이므로 레거시 인증 방법 사용(Legacy Authentication Method)을 선택한다.

 

 

설치 완료!

 

 

3) 안전한 MySQL 설치

MySQL Server는 mysql_secure_installation 스크립트와 함께 제공되며, 여러 보안 관련 작업을 수행할 수 있습니다.

mysql_secure_installation

보안과 관련된 설정을 하기 위해 명령어를 입력하면 이전에 설정한 root 계정의 비밀번호를 입력한다.

 

 

root 계정의 비밀번호를 입력하고 나면 아래와 같이 몇 가지 보안과 관련된 설정을 하게 되는데 상황에 맞게 설정하면 한다.

개발용 테스트 서버라는 상황에 맞게 설정하였다.

// 암호의 강도 설정
VALIDATE PASSWORD COMPONENT can be used to test passwords and improve security. It checks the strength of password and allows the users to set only those passwords which are secure enough. Would you like to setup VALIDATE PASSWORD component?
Press y|Y for Yes, any other key for No: No

// 루트 패스워드 변경
Using existing password for root. Change the password for root ?
((Press y|Y for Yes, any other key for No) : No

... skipping. By default, a MySQL installation has an anonymous user, allowing anyone to log into MySQL without having to have a user account created for them. This is intended only for testing, and to make the installation go a bit smoother. You should remove them before moving into a production environment.

// 익명 사용자 삭제
Remove anonymous users? (Press y|Y for Yes, any other key for No) : y

Normally, root should only be allowed to connect from 'localhost'. This ensures that someone cannot guess at the root password from the network.

// root 사용자 원격 접속 
Disallow root login remotely? (Press y|Y for Yes, any other key for No) : No

... skipping. By default, MySQL comes with a database named 'test' that anyone can access. This is also intended only for testing, and should be removed before moving into a production environment.

// test database 삭제
Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y
- Dropping test database...
Success.

- Removing privileges on test database...
Success.

Reloading the privilege tables will ensure that all changes made so far will take effect immediately.
// 권한 적용
Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y
Success.

All done!

 

4) MySQL Database 로그인
mysql -u root -p

 

설정까지 완료.

 

5) MySQL 원격 계정 생성

 

먼저 root 사용자로 MySQL 서버에 로그인합니다.

 

mysql -u root -p

 

MySQL Shell에 접속되면 사용자를 생성합니다. (예제: test 계정 생성)

 

CREATE USER 'test'@'%' IDENTIFIED BY 'test1234';

 

생성된 사용자에게 데이터베이스 권한을 할당 합니다. 예제 에서는 생성된 test 사용자에게 모든 권한을 할당합니다.

 

GRANT ALL PRIVILEGES ON *.* TO 'test'@'%';

 

생성된 권한을 적용 합니다.

 

FLUSH PRIVILEGES;

 

적용이 완료되었으면, 생성된 사용자 정보를 확인 합니다.

 

mysql> use mysql;
mysql> SELECT host,user,plugin,authentication_string FROM user;

 

콘솔 명령어 또는 Client 프로그램(HeidiSQL)으로 접속을 확인합니다.

 

mysql -h [MySQL IP] -u test -p

 

 

원격 계정 설정 완료!!!

 

참고) MySQL 서비스 관련 명령어
// 서비스 시작
sudo systemctl start mysql.service

// 서비스 중지
sudo systemctl stop msyql.service

// 서비스 재시작
sudo systemctl restart mysql.service

// 서비스 상태 확인
sudo systemctl status mysql.service 

 

반응형

'WEB & Mobile' 카테고리의 다른 글

[Node.js]우분투 node.js 설치  (1) 2019.02.21
[MySQL]Window MySQL 한글 설정  (0) 2017.07.29
[Node.js]node.js 요청 과 응답 객체  (0) 2017.07.14
[Node.js]node.js 개발 환경 설정  (2) 2017.05.19
[SITE]Gravatar(그라바타)  (0) 2015.06.05

관련글 더보기

댓글 영역