본문 바로가기
공유방/OS 정보

[CentOS] MariaDB 설치 및 설정, 실행

by MoelCano 2021. 7. 25.
반응형

1. MariaDB 패키지 설치하기

 [CMD] sudo yum install mariadb-server -y

 

2. MariaDB 실행

 [CMD] systemctl start mariadb

 

3 재부팅 시 자동 실행 설정

 [CMD] systemctl enable mariadb

 

4. MariaDB 설정

 [CMD] mysql_secure_installation

------------------------------

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
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none):
OK, successfully used password, moving on...

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

You already have a root password set, so you can safely answer 'n'.

Change the root password? [Y/n] n

루트 암호를 변경하시겠습니까?
 ... skipping.

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.
기본적으로 MariaDB 설치에는 익명 사용자가 있으며, 모든 사용자에게 허용됩니다.
다음에 대한 사용자 계정을 만들 필요 없이 MariaDB에 로그인하려면
테스트용이며 설치용으로만 사용됩니다.
좀 더 부드럽게. 이동하기 전에 제거해야 합니다.

Remove anonymous users? [Y/n] Y

익명 사용자를 제거하시겠습니까? [Y/n] 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

원격으로 루트 로그인을 허용하지 않으시겠습니까? [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] Y
 ... Success!.

Cleaning up...

All done!  If you've completed all of the above steps, your MariaDB
installation should now be secure.
완료~

------------------------------

 

5. MariaDB 서비스 확인

 [CMD] systemctl status mariadb

 

6. Console 상태에서 DB  접속

 [CMD] mysql -u root -p

 

7. 데이터베이스 생성

 [CMD] create database db_name character set ='utf8' collate='utf8_general_ci';

 

8. 데이터베이스 확인

 [CMD] show databases;

 

9. 데이터베이스 접속

 [CMD] use db_name;

 

10. root 권한 부여

 [MariaDB [(none)] >  grant all privileges on *.* to 'root'@'%' identified by '비밀번호';

 

11. Port 변경

 conf 파일이 다소 다른 것으로 확인이 되는데,  설치 마리아버전 10.3.28 기준으로

 /etc/my.cnf.d/mariadb-server.cnf에서 설정하였습니다.

 [mysqld]

 port=포트번호

최근에 컴퓨터를 바꾸면서 재 설치를 하면서 업데이트 합니다.

[mariadb]
port=포트번호

 

 방화벽 오픈 

 [CMD] firewall-cmd --permanent --add-port=포트번호/tcp

 [CMD] firewall-cmd --reload

 

11.  MariaDB 재시작

 [CMD] systemctl restart mariadb

반응형