홈서버/debian

[11]홈서버 mariadb 설치하기

oksoosoo 2020. 8. 25. 22:53

mariadb 홈페이지에 접속하여 다운로드 방법을 확인할 수 있다.

(https://downloads.mariadb.org/mariadb/repositories/#distro=Debian&distro_release=buster--buster&mirror=yongbok&version=10.5)

 

사전작업

sudo apt-get install software-properties-common dirmngr
sudo apt-key adv --fetch-keys 'https://mariadb.org/mariadb_release_signing_key.asc'
sudo add-apt-repository 'deb [arch=amd64] https://mirror.yongbok.net/mariadb/repo/10.5/debian buster main'

 

 

업데이트 후 설치하여 준다.

sudo apt update
sudo apt install mariadb-server

 

 

설치가 완료되면 설정을 진행하여 준다.

sudo mysql_secure_installation

 

 

root 비번을 입력하라고 한다. 그냥 엔터를 쳐도 무방하다.

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we'll need the current
password for the root user. If you've just installed MariaDB, and
haven't set the root password yet, you should just press enter here.

Enter current password for root (enter for none):

 

 

root 계정의 암호로 접속하면 비번 없이 접속할 수 있는 옵션인 거 같다.

아닐 수 도 있다.

Y를 해주었다.

OK, successfully used password, moving on...

Setting the root password or using the unix_socket ensures that nobody
can log into the MariaDB root user without the proper authorisation.

You already have your root account protected, so you can safely answer 'n'.

Switch to unix_socket authentication [Y/n]

 

 

root 패스워드를 변경할 것인지 물어본다. Y

Enabled successfully!
Reloading privilege tables..
 ... Success!


You already have your root account protected, so you can safely answer 'n'.

Change the root password? [Y/n]

 

 

패스워드를 다시 설정해 준다.

New password:
Re-enter new password:

 

 

익명 사용자를 삭제할지 물어본다. Y

Password updated successfully!
Reloading privilege tables..
 ... Success!


By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB 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? [Y/n]

 

 

원격 root 계정의 접속을 허용할지 물어본다.

허용이 root 계정의 접속은 굳이 필요 없을것 같다. Y

 ... Success!

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

Disallow root login remotely? [Y/n]

 

 

테스트 데이터베이스를 삭제할지 물어본다. Y

 ... Success!

By default, MariaDB 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.

Remove test database and access to it? [Y/n]

 

 

권한 테이블을 다시 로드할지 물어본다.

즉시 효력이 발생한다고 한다. 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? [Y/n]

 

 

설정파일에서 언어 설정만 수정하여 줄 것이다.

 sudo vim /etc/mysql/mariadb.conf.d/50-server.cnf

 

 

94번 줄에 있는 위에 줄 내용을 아래 줄 내용으로 수정하여 준다.

안 해도 무방하다. 하는 이유는 속도가 빨라진다고 햇던거 같다.

collation-server      = utf8mb4_general_ci
collation-server      = utf8mb4_unicode_ci

 

 

mysql을 다시 실행하여 준다.

sudo service mysql restart

 

 

db에 접속하여 본다.

user@oksoo:~$ sudo mysql -u root -p
Enter password:

 

 

접속이 완료되었다.

Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 31
Server version: 10.5.5-MariaDB-1:10.5.5+maria~buster mariadb.org binary distribution

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]>