2023년 신상 호텔 리스트
최근에 오픈한 호텔을 찾는다면 살펴보세요

Ubuntu - MySQL 설치하기

조회수: 787

터미널에서 sudo apt update 그리고 sudo apt install mysql-server 실행하자.

Reading package lists... Done

Building dependency tree       

Reading state information... Done

The following additional packages will be installed:

  libaio1 libcgi-fast-perl libcgi-pm-perl libencode-locale-perl libevent-core-2.1-6 libfcgi-perl libhtml-parser-perl

  libhtml-tagset-perl libhtml-template-perl libhttp-date-perl libhttp-message-perl libio-html-perl

  liblwp-mediatypes-perl libtimedate-perl liburi-perl mysql-client-5.7 mysql-client-core-5.7 mysql-common

  mysql-server-5.7 mysql-server-core-5.7

Suggested packages:

  libdata-dump-perl libipc-sharedcache-perl libwww-perl mailx tinyca

The following NEW packages will be installed:

  libaio1 libcgi-fast-perl libcgi-pm-perl libencode-locale-perl libevent-core-2.1-6 libfcgi-perl libhtml-parser-perl

  libhtml-tagset-perl libhtml-template-perl libhttp-date-perl libhttp-message-perl libio-html-perl

  liblwp-mediatypes-perl libtimedate-perl liburi-perl mysql-client-5.7 mysql-client-core-5.7 mysql-common

  mysql-server mysql-server-5.7 mysql-server-core-5.7

0 upgraded, 21 newly installed, 0 to remove and 18 not upgraded.

Need to get 19.6 MB of archives.

After this operation, 156 MB of additional disk space will be used.

Do you want to continue? [Y/n] 

Y 치고 엔터 누르면 설치가 된다.

Get:1 http://archive.ubuntu.com/ubuntu bionic/main amd64 mysql-common all 5.8+1.0.4 [7,308 B]

Get:2 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 libaio1 amd64 0.3.110-5ubuntu0.1 [6,476 B]

Get:3 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 mysql-client-core-5.7 amd64 5.7.35-0ubuntu0.18.04.1 [6,627 kB]

Get:4 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 mysql-client-5.7 amd64 5.7.35-0ubuntu0.18.04.1 [1,944 kB]

Get:5 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 mysql-server-core-5.7 amd64 5.7.35-0ubuntu0.18.04.1 [7,420 kB]

Get:6 http://archive.ubuntu.com/ubuntu bionic/main amd64 libevent-core-2.1-6 amd64 2.1.8-stable-4build1 [85.9 kB]

Get:7 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 mysql-server-5.7 amd64 5.7.35-0ubuntu0.18.04.1 [2,905 kB]

Get:8 http://archive.ubuntu.com/ubuntu bionic/main amd64 libhtml-tagset-perl all 3.20-3 [12.1 kB]

Get:9 http://archive.ubuntu.com/ubuntu bionic/main amd64 liburi-perl all 1.73-1 [77.2 kB]

Get:10 http://archive.ubuntu.com/ubuntu bionic/main amd64 libhtml-parser-perl amd64 3.72-3build1 [85.9 kB]

Get:11 http://archive.ubuntu.com/ubuntu bionic/main amd64 libcgi-pm-perl all 4.38-1 [185 kB]

Get:12 http://archive.ubuntu.com/ubuntu bionic/main amd64 libfcgi-perl amd64 0.78-2build1 [32.8 kB]

Get:13 http://archive.ubuntu.com/ubuntu bionic/main amd64 libcgi-fast-perl all 1:2.13-1 [9,940 B]

Get:14 http://archive.ubuntu.com/ubuntu bionic/main amd64 libencode-locale-perl all 1.05-1 [12.3 kB]

Get:15 http://archive.ubuntu.com/ubuntu bionic/main amd64 libhtml-template-perl all 2.97-1 [59.0 kB]

Get:16 http://archive.ubuntu.com/ubuntu bionic/main amd64 libtimedate-perl all 2.3000-2 [37.5 kB]

Get:17 http://archive.ubuntu.com/ubuntu bionic/main amd64 libhttp-date-perl all 6.02-1 [10.4 kB]

Get:18 http://archive.ubuntu.com/ubuntu bionic/main amd64 libio-html-perl all 1.001-1 [14.9 kB]

Get:19 http://archive.ubuntu.com/ubuntu bionic/main amd64 liblwp-mediatypes-perl all 6.02-1 [21.7 kB]

Get:20 http://archive.ubuntu.com/ubuntu bionic/main amd64 libhttp-message-perl all 6.14-1 [72.1 kB]

Get:21 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 mysql-server all 5.7.35-0ubuntu0.18.04.1 [9,944 B]

Fetched 19.6 MB in 5s (3,922 kB/s)  

Preconfiguring packages ...

Selecting previously unselected package mysql-common.

(Reading database ... 103135 files and directories currently installed.)

Preparing to unpack .../0-mysql-common_5.8+1.0.4_all.deb ...

Unpacking mysql-common (5.8+1.0.4) ...

Selecting previously unselected package libaio1:amd64.

Preparing to unpack .../1-libaio1_0.3.110-5ubuntu0.1_amd64.deb ...

Unpacking libaio1:amd64 (0.3.110-5ubuntu0.1) ...

Selecting previously unselected package mysql-client-core-5.7.

Preparing to unpack .../2-mysql-client-core-5.7_5.7.35-0ubuntu0.18.04.1_amd64.deb ...

Unpacking mysql-client-core-5.7 (5.7.35-0ubuntu0.18.04.1) ...

Selecting previously unselected package mysql-client-5.7.

Preparing to unpack .../3-mysql-client-5.7_5.7.35-0ubuntu0.18.04.1_amd64.deb ...

Unpacking mysql-client-5.7 (5.7.35-0ubuntu0.18.04.1) ...

Selecting previously unselected package mysql-server-core-5.7.

Preparing to unpack .../4-mysql-server-core-5.7_5.7.35-0ubuntu0.18.04.1_amd64.deb ...

Unpacking mysql-server-core-5.7 (5.7.35-0ubuntu0.18.04.1) ...

Selecting previously unselected package libevent-core-2.1-6:amd64.

Preparing to unpack .../5-libevent-core-2.1-6_2.1.8-stable-4build1_amd64.deb ...

Unpacking libevent-core-2.1-6:amd64 (2.1.8-stable-4build1) ...

Setting up mysql-common (5.8+1.0.4) ...

update-alternatives: using /etc/mysql/my.cnf.fallback to provide /etc/mysql/my.cnf (my.cnf) in auto mode

Selecting previously unselected package mysql-server-5.7.

(Reading database ... 103303 files and directories currently installed.)

Preparing to unpack .../00-mysql-server-5.7_5.7.35-0ubuntu0.18.04.1_amd64.deb ...

Unpacking mysql-server-5.7 (5.7.35-0ubuntu0.18.04.1) ...

Selecting previously unselected package libhtml-tagset-perl.

Preparing to unpack .../01-libhtml-tagset-perl_3.20-3_all.deb ...

Unpacking libhtml-tagset-perl (3.20-3) ...

Selecting previously unselected package liburi-perl.

Preparing to unpack .../02-liburi-perl_1.73-1_all.deb ...

Unpacking liburi-perl (1.73-1) ...

Selecting previously unselected package libhtml-parser-perl.

Preparing to unpack .../03-libhtml-parser-perl_3.72-3build1_amd64.deb ...

Unpacking libhtml-parser-perl (3.72-3build1) ...

Selecting previously unselected package libcgi-pm-perl.

Preparing to unpack .../04-libcgi-pm-perl_4.38-1_all.deb ...

Unpacking libcgi-pm-perl (4.38-1) ...

Selecting previously unselected package libfcgi-perl.

Preparing to unpack .../05-libfcgi-perl_0.78-2build1_amd64.deb ...

Unpacking libfcgi-perl (0.78-2build1) ...

Selecting previously unselected package libcgi-fast-perl.

Preparing to unpack .../06-libcgi-fast-perl_1%3a2.13-1_all.deb ...

Unpacking libcgi-fast-perl (1:2.13-1) ...

Selecting previously unselected package libencode-locale-perl.

Preparing to unpack .../07-libencode-locale-perl_1.05-1_all.deb ...

Unpacking libencode-locale-perl (1.05-1) ...

Selecting previously unselected package libhtml-template-perl.

Preparing to unpack .../08-libhtml-template-perl_2.97-1_all.deb ...

Unpacking libhtml-template-perl (2.97-1) ...

Selecting previously unselected package libtimedate-perl.

Preparing to unpack .../09-libtimedate-perl_2.3000-2_all.deb ...

Unpacking libtimedate-perl (2.3000-2) ...

Selecting previously unselected package libhttp-date-perl.

Preparing to unpack .../10-libhttp-date-perl_6.02-1_all.deb ...

Unpacking libhttp-date-perl (6.02-1) ...

Selecting previously unselected package libio-html-perl.

Preparing to unpack .../11-libio-html-perl_1.001-1_all.deb ...

Unpacking libio-html-perl (1.001-1) ...

Selecting previously unselected package liblwp-mediatypes-perl.

Preparing to unpack .../12-liblwp-mediatypes-perl_6.02-1_all.deb ...

Unpacking liblwp-mediatypes-perl (6.02-1) ...

Selecting previously unselected package libhttp-message-perl.

Preparing to unpack .../13-libhttp-message-perl_6.14-1_all.deb ...

Unpacking libhttp-message-perl (6.14-1) ...

Selecting previously unselected package mysql-server.

Preparing to unpack .../14-mysql-server_5.7.35-0ubuntu0.18.04.1_all.deb ...

Unpacking mysql-server (5.7.35-0ubuntu0.18.04.1) ...

Setting up libhtml-tagset-perl (3.20-3) ...

Setting up libevent-core-2.1-6:amd64 (2.1.8-stable-4build1) ...

Setting up libencode-locale-perl (1.05-1) ...

Setting up libtimedate-perl (2.3000-2) ...

Setting up libio-html-perl (1.001-1) ...

Setting up liblwp-mediatypes-perl (6.02-1) ...

Setting up libaio1:amd64 (0.3.110-5ubuntu0.1) ...

Setting up liburi-perl (1.73-1) ...

Setting up libhtml-parser-perl (3.72-3build1) ...

Setting up libcgi-pm-perl (4.38-1) ...

Setting up mysql-client-core-5.7 (5.7.35-0ubuntu0.18.04.1) ...

Setting up libfcgi-perl (0.78-2build1) ...

Setting up libhttp-date-perl (6.02-1) ...

Setting up libhtml-template-perl (2.97-1) ...

Setting up mysql-server-core-5.7 (5.7.35-0ubuntu0.18.04.1) ...

Setting up libcgi-fast-perl (1:2.13-1) ...

Setting up libhttp-message-perl (6.14-1) ...

Setting up mysql-client-5.7 (5.7.35-0ubuntu0.18.04.1) ...

Setting up mysql-server-5.7 (5.7.35-0ubuntu0.18.04.1) ...

update-alternatives: using /etc/mysql/mysql.cnf to provide /etc/mysql/my.cnf (my.cnf) in auto mode

Renaming removed key_buffer and myisam-recover options (if present)

Created symlink /etc/systemd/system/multi-user.target.wants/mysql.service → /lib/systemd/system/mysql.service.

Setting up mysql-server (5.7.35-0ubuntu0.18.04.1) ...

Processing triggers for libc-bin (2.27-3ubuntu1.4) ...

Processing triggers for systemd (237-3ubuntu10.50) ...

Processing triggers for man-db (2.8.3-2ubuntu0.1) ...

Processing triggers for ureadahead (0.100.0-21) ...

 

이제 sudo mysql_secure_installation 실행하자.

Securing the MySQL server deployment.

Connecting to MySQL using a blank password.

VALIDATE PASSWORD PLUGIN 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 plugin?

Press y|Y for Yes, any other key for No: 

필수는 아니다. 보안을 강하게 하려면 y 타이핑하고 엔터. 

0, 1, 2 중에 강한 2번 선택하자.

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:

 

질문이 계속 나온다. 다 Y하면 된다. 

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

 

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)

 

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? (Press y|Y for Yes, any other key for No)

 

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.

Remove test database and access to it? (Press y|Y for Yes, any other key for No) :

 

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

 

root가 password 대신 auth_socket으로 설정이 되어 있다.

만약 password로 변경하길 원한다면 sudo mysql 실행하자.

그럼 mysql> 이 나타난다.

아래와 같이 타이핑한 후 실행하자. 그럼 Query OK, 0 rows affected (0.01 sec)라고 나올 것이다.

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '비밀번호';

 

제대로 되었는지 확인을 하기 위해서 SELECT user,authentication_string,plugin,host FROM mysql.user; 실행해보자. plugin이 auth_socket 말고 mysql_native_password로 되어 있을 것이다.

 

mysql>에서 나가려면 exit 치고 실행하면 된다.

password로 설정을 했다면 mysql -u root -p 실행 후 설정한 password 넣으면 접속이 된다.