반응형

안녕하세요 가야태자 @talkit 입니다. 

오늘 제가 앞으로 설치하려는 프로그램 때문에 데이터베이스가 필요해서 우분투 리눅스에 데이터베이스를 설치해보겠습니다. 

우선 당연히 우분투 리눅스에 접속 합니다. ^^

잘 접속 하셨다고 생각하고 깔아 보도록 하겠습니다. ^^

sudo apt update

우선 최신 업데이트가 있는지 확인 합니다. 

보통은 비밀번호를 한번 넣어 줘야 하지만 ^^

저희는 비밀번호를 넣지 않아도 되네요 ^^

sudo apt install mysql-server

업데이트가 끝나면 위 명령어를 입력하시면 됩니다. 

sudo apt install mysql-server
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
  libcgi-fast-perl libcgi-pm-perl libclone-perl libencode-locale-perl libevent-pthreads-2.1-7 libfcgi-bin libfcgi-perl libfcgi0ldbl libhtml-parser-perl libhtml-tagset-perl libhtml-template-perl libhttp-date-perl libhttp-message-perl libio-html-perl liblwp-mediatypes-perl libmecab2 libprotobuf-lite23 libtimedate-perl liburi-perl mecab-ipadic mecab-ipadic-utf8
  mecab-utils mysql-client-8.0 mysql-client-core-8.0 mysql-common mysql-server-8.0 mysql-server-core-8.0
Suggested packages:
  libdata-dump-perl libipc-sharedcache-perl libbusiness-isbn-perl libwww-perl mailx tinyca
The following NEW packages will be installed:
  libcgi-fast-perl libcgi-pm-perl libclone-perl libencode-locale-perl libevent-pthreads-2.1-7 libfcgi-bin libfcgi-perl libfcgi0ldbl libhtml-parser-perl libhtml-tagset-perl libhtml-template-perl libhttp-date-perl libhttp-message-perl libio-html-perl liblwp-mediatypes-perl libmecab2 libprotobuf-lite23 libtimedate-perl liburi-perl mecab-ipadic mecab-ipadic-utf8
  mecab-utils mysql-client-8.0 mysql-client-core-8.0 mysql-common mysql-server mysql-server-8.0 mysql-server-core-8.0
0 upgraded, 28 newly installed, 0 to remove and 20 not upgraded.
Need to get 29.4 MB of archives.
After this operation, 242 MB of additional disk space will be used.
Do you want to continue? [Y/n]

그러면 계속 할꺼냐고 묻는데 ^^ 다연히 Y를 입력 합니다. 

정말 간단하네요 ^^

쭉 설치가 이루어지고, 중간에 커널관련된 메시지가 떴는데 캡쳐를 못해서 ^^ OK 두번 눌러 주시면 됩니다. 

mysql client 까지 잘 설치 되었습니다. 

sudo mysql_secure_installation

보안 설정과 root 비밀번호 설정을 위해서 위 프로그램을 실행해 줍니다. 

Securing the MySQL server deployment.

Connecting to MySQL using a blank password.

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: Y

보안 때문에 비밀번호를 넣는게 좋다 넣겠느냐? 당연히 Y를 누르셔야 합니다. ^^

There are three levels of password validation policy:

LOW    Length >= 8
MEDIUM Length >= 8, numeric, mixed case, and special characters
STRONG Length >= 8, numeric, mixed case, special characters and dictionary                  file

Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG:

정책적으로 쉬운 비밀번호를 쓸꺼냐 어려운 비밀번호를 쓸꺼냐? 물으면 일단 어려운 비밀번호를 선택해야겠지요 ^^ 하지만, 비밀번호 만들기 규칙이 좀 쉬워야 하니까 다른 방법으로 보안을 신경 써줘야 해서 여기서는 MEDIUM 중간정도를 선택 하겠습니다. ^^

그래서 여기는 1을 넣습니다. 

Please set the password for root here.

New password:

요렇게 나오면 비밀번호를 대소문자를 넣으시고, 특수문자를 썩어서 8자리 이상의 비밀번호를 만드시면 됩니다. 

저는 매일 사용하는 비밀번호가 있어서 넣었습니다. 

Estimated strength of the password: 50
Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) :

그랬더니 니가 제공한 비밀번호는 50점 정도 되는데 그래도 쓸래 라고 합니다. 저는 Y를 눌러야지요 ^^

 ... Failed! Error: SET PASSWORD has no significance for user 'root'@'localhost' as the authentication method used doesn't store authentication data in the MySQL server. Please consider using ALTER USER instead if you want to change authentication parameters.

New password:

저 처럼 위와 같이 오류가 나면 해당 쉘을 종료 하십시오 ^^

그리고 다른 방법으로 비밀번호를 변경 합니다. ^^

sudo mysql
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '원하는비밀번호';

여기서 원하는 비밀번호는 아까 만든신 비밀번호 규칙을 잘 따르셔야 합니다. ^^

sudo mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 13
Server version: 8.0.31-0ubuntu0.22.04.1 (Ubuntu)

Copyright (c) 2000, 2022, 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.

mysql>

자 이제 제가 원하는 대로 mysql 에 접속이 되네요 간단하게 한번 몇개 명령어만 더 내리고 오늘은 여기까지 글을 마무리 하겠습니다. ^^

show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
4 rows in set (0.01 sec)

show databases; 명령어는 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

use 명령어는 사용하고자 하는 데이터베이스를  선택해 줍니다. 

 show tables;
+------------------------------------------------------+
| Tables_in_mysql                                      |
+------------------------------------------------------+
| columns_priv                                         |
| component                                            |
| db                                                   |
| default_roles                                        |
| engine_cost                                          |
| func                                                 |
| general_log                                          |
| global_grants                                        |
| gtid_executed                                        |
| help_category                                        |
| help_keyword                                         |
| help_relation                                        |
| help_topic                                           |
| innodb_index_stats                                   |
| innodb_table_stats                                   |
| password_history                                     |
| plugin                                               |
| procs_priv                                           |
| proxies_priv                                         |
| replication_asynchronous_connection_failover         |
| replication_asynchronous_connection_failover_managed |
| replication_group_configuration_version              |
| replication_group_member_actions                     |
| role_edges                                           |
| server_cost                                          |
| servers                                              |
| slave_master_info                                    |
| slave_relay_log_info                                 |
| slave_worker_info                                    |
| slow_log                                             |
| tables_priv                                          |
| time_zone                                            |
| time_zone_leap_second                                |
| time_zone_name                                       |
| time_zone_transition                                 |
| time_zone_transition_type                            |
| user                                                 |
+------------------------------------------------------+
37 rows in set (0.00 sec)

show tables 명령어는 데이터베이스 내에 있는 테이블들을 나열해 줍니다. 

정말 잘 설치 되었습니다. 

Tasks: 116 total,   1 running, 115 sleeping,   0 stopped,   0 zombie
%Cpu(s):  0.0 us,  0.2 sy,  0.0 ni, 99.8 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
MiB Mem :    964.1 total,     74.0 free,    571.1 used,    319.1 buff/cache
MiB Swap:      0.0 total,      0.0 free,      0.0 used.    231.9 avail Mem

아직 데이터를 넣지 않아서 그렇지만, ^^

CPU는 훌륭하네요 ^^ 1VPU이긴 하지만, 충분히 MySQL이 저혼자 쓸때는 잘 돌아 갑니다. ^^

그리고 메모리는 흑흑흑 실제로 운영을 해봐야겠지만 조금 모자랄 수도 있을 것 같습니다. ^^

감사합니다. 

반응형

+ Recent posts