본문 바로가기

개발/MySQL

MySQL 8 설치

반응형

 

 

MySQL 8을 설치 해 보자. 나중에 까먹지마 ㅠㅠ

두근두근..

 

CentOS Linux release 7.6.1810 (Core) 환경에 MySQL 8 설치하기 시작!

 

 

 

저장소 추가하기

# yum install -y https://dev.mysql.com/get/mysql80-community-release-el7-11.noarch.rpm
Loaded plugins: fastestmirror
mysql80-community-release-el7-11.noarch.rpm                         |  14 kB  00:00:00
Examining /var/tmp/yum-root-4ePacN/mysql80-community-release-el7-11.noarch.rpm: mysql80-community-release-el7-11.noarch
Marking /var/tmp/yum-root-4ePacN/mysql80-community-release-el7-11.noarch.rpm as an update to mysql80-community-release-el7-3.noarch
Resolving Dependencies
--> Running transaction check
---> Package mysql80-community-release.noarch 0:el7-3 will be updated
---> Package mysql80-community-release.noarch 0:el7-11 will be an update
--> Finished Dependency Resolution

Dependencies Resolved
.
.
.
Upgrade  1 Package

Total size: 17 k
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Updating   : mysql80-community-release-el7-11.noarch                1/2
  Cleanup    : mysql80-community-release-el7-3.noarch                 2/2
  Verifying  : mysql80-community-release-el7-11.noarch                1/2
  Verifying  : mysql80-community-release-el7-3.noarch                 2/2

Updated:
  mysql80-community-release.noarch 0:el7-11

Complete!

저장소를 추가 안하면 5.x 버전이 설치된다고 한다.

 

 

 

 

MySQL 설치

# yum install -y mysql-community-server
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirror.kakao.com
 * epel: mirror-icn.yuki.net.uk
 * extras: mirror.kakao.com
 * updates: mirror.kakao.com
Resolving Dependencies
--> Running transaction check
---> Package mysql-community-server.x86_64 0:8.0.36-1.el7 will be installed
--> Processing Dependency: mysql-community-common(x86-64) = 8.0.36-1.el7 for package: mysql-community-server-8.0.36-1.el7.x86_64
--> Processing Dependency: mysql-community-icu-data-files = 8.0.36-1.el7 for package: mysql-community-server-8.0.36-1.el7.x86_64
--> Processing Dependency: mysql-community-client(x86-64) >= 8.0.11 for package: mysql-community-server-8.0.36-1.el7.x86_64
--> Running transaction check
---> Package mysql-community-client.x86_64 0:8.0.36-1.el7 will be installed
--> Processing Dependency: mysql-community-client-plugins = 8.0.36-1.el7 for package: mysql-community-client-8.0.36-1.el7.x86_64
--> Processing Dependency: mysql-community-libs(x86-64) >= 8.0.11 for package: mysql-community-client-8.0.36-1.el7.x86_64
---> Package mysql-community-common.x86_64 0:8.0.36-1.el7 will be installed
---> Package mysql-community-icu-data-files.x86_64 0:8.0.36-1.el7 will be installed
--> Running transaction check
---> Package mysql-community-client-plugins.x86_64 0:8.0.36-1.el7 will be installed
---> Package mysql-community-libs.x86_64 0:8.0.36-1.el7 will be installed
--> Finished Dependency Resolution
.
.
.
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : mysql-community-common-8.0.36-1.el7.x86_64                          1/6
  Installing : mysql-community-client-plugins-8.0.36-1.el7.x86_64                  2/6
  Installing : mysql-community-libs-8.0.36-1.el7.x86_64                            3/6
  Installing : mysql-community-client-8.0.36-1.el7.x86_64                          4/6
  Installing : mysql-community-icu-data-files-8.0.36-1.el7.x86_64                  5/6
  Installing : mysql-community-server-8.0.36-1.el7.x86_64                          6/6
  Verifying  : mysql-community-client-8.0.36-1.el7.x86_64                          1/6
  Verifying  : mysql-community-client-plugins-8.0.36-1.el7.x86_64                  2/6
  Verifying  : mysql-community-server-8.0.36-1.el7.x86_64                          3/6
  Verifying  : mysql-community-common-8.0.36-1.el7.x86_64                          4/6
  Verifying  : mysql-community-libs-8.0.36-1.el7.x86_64                            5/6
  Verifying  : mysql-community-icu-data-files-8.0.36-1.el7.x86_64                  6/6

Installed:
  mysql-community-server.x86_64 0:8.0.36-1.el7

Dependency Installed:
  mysql-community-client.x86_64 0:8.0.36-1.el7      mysql-community-client-plugins.x86_64 0:8.0.36-1.el7      mysql-community-common.x86_64 0:8.0.36-1.el7      mysql-community-icu-data-files.x86_64 0:8.0.36-1.el7      mysql-community-libs.x86_64 0:8.0.36-1.el7

Complete!

설치 완료!!

 

 

 

 

설치 잘 됐나 버전확인

# mysql -version
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)

왜 에러나 이거 뭐야 무서워..

실서버 운영할때 MySQL 장애와 저 에러를 많이 봐서 트라우마가..ㅠㅠ

 

 

MySQL 시작을 안해서 발생하는 에러였군 ㅋㅋ 휴..

아래 명령어로 상태를 볼 수 있음

# systemctl status mysqld
● mysqld.service - MySQL Server
   Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
   Active: inactive (dead)
     Docs: man:mysqld(8)
           http://dev.mysql.com/doc/refman/en/using-systemd.html

 

 

 

 

 

 

MySQL 시작

# systemctl start mysql
Failed to start mysql.service: Unit not found.

또 에러나네,

 

[root@drvsms home]# systemctl start mysqld
[root@drvsms home]# mysql --version
mysql  Ver 8.0.36 for Linux on x86_64 (MySQL Community Server - GPL)

mysql 아니고 mysqld 였음 ㅋㅋ 버전도 잘 나오고 통과!!

 

 

 

 

 

서버 재시작시 MySQL 자동으로 실행되도록 설정

# systemctl enable mysqld

 

 

 

 

 

 

임시 root 비밀번호 확인

# grep 'temporary password' /var/log/mysqld.log
2024-03-29T01:56:53.565061Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: 여기에임시비밀번호

처음 설치시 root 비밀번호가 임시로 발급된다.

비번 없으면 막 쳐들어와서 그런가?..

 

 

 

 

 

임시 root 비밀번호로 로그인

# mysql -u root -p
Enter password: 위에발급된임시비밀번호
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.36

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

 

 

 

root 로그인해서 DB보려고 했더니...

mysql> show databases;
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.

비밀번호 먼저 리셋하란다!!

 

 

 

 

 

 

root 비밀번호 변경

mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY '새로운root비밀번호';
Query OK, 0 rows affected (0.01 sec)

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

이제 databases 잘 보인다~~

 

 

 

 

 

 

mysql_secure_installation 보안설정

# mysql_secure_installation

Securing the MySQL server deployment.

Enter password for user root:
The 'validate_password' component is installed on the server.
The subsequent steps will run with the existing configuration
of the component.
Using existing password for root.

Estimated strength of the password: 100
Change the password for root ? ((Press y|Y for Yes, any other key for No) : n

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

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

 

  • root 비밀번호 바꾸꺼냐? 이미 설정 했으니깐 No
  • 익명 사용자 지우꺼냐? 지워줘라 Yes
  • root 로그인 원격 접속 막으냐? 막아야 보안이 좋으니깐 Yes
  • test database 지우꺼냐? 지워라! Yes
  • 지금 적용할꺼냐? 해줘라 Yes

아, 요거는 mysql root 로그인 했던거 exit 로 나와서 실행해야 함

 

 

 

 

DB및 사용자 추가

mysql> create database playon;
mysql> create user 'playon'@'localhost' identified by 'playondbpassword';
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements

DB를 추가 하고 사용자를 추가하려고 했더니,

오 뭐야 에러가..

비밀번호가 약한가 해서 숫자와 특수문자까지 넣었지만 같은 에러..

대문자도 넣어야 할거 같지만 넘 내가 이기고 싶어서(ㅋㅋㅋㅋㅋ) 보안을 낮추겠다!!

 

 

 

비밀번호 

보안을 좀 낮추고,

mysql> SET GLOBAL validate_password.policy = LOW;
Query OK, 0 rows affected (0.00 sec)

mysql> create user 'playon'@'localhost' identified by 'playondbpassword';
Query OK, 0 rows affected (0.01 sec)

등록 잘 된다 ㅋㅋㅋ

내가 MySQL 이김(???)

 

반응형

'개발 > MySQL' 카테고리의 다른 글

MySQL 8 사용자 추가  (0) 2022.07.07
root 비번 변경  (1) 2017.12.29
root 비번을 바꿔보자  (0) 2017.12.21