1.MySQL 압축 해제
[root@mysql8 ~]# ls
mysql-commercial-8.0.22-el7-x86_64.tar.gz
[root@mysql8 ~]# tar -zxvf mysql-commercial-8.0.22-el7-x86_64.tar.gz
2.MySQL User & Directory 설정
[root@mysql8 ~]# groupadd mysql
[root@mysql8 ~]# useradd -g mysql mysql
[root@mysql8 ~]# mkdir -p /data/data
[root@mysql8 ~]# chown -R mysql.mysql /data
3./etc/my.cnf 설정 변경
[root@mysql8 ~]#cp /etc/my.cnf /etc/my.cnf_cp
[root@mysql8 ~]# cat > /etc/my.cnf <<EOF
[mysqld]
datadir=/data/data
socket=/tmp/mysql.sock
log-error=/data/mysql.err
pid-file=/data/mysql.pid
symbolic-links=0
[mysqld_safe]
log-error=/data/mysql.err
pid-file=/data/mysql.pid
!includedir /etc/my.cnf.d
EOF
4. 설치
[root@mysql8 ~]# mv mysql-commercial-8.0.22-el7-x86_64 /data/mysql
[root@mysql8 bin]# /data/mysql/bin/mysqld --initialize --user=mysql
[root@mysql8 bin]# /data/mysql/bin/mysqld_safe --user=mysql &
[1] 7181
[root@mysql8 bin]# 2021-11-10T03:55:09.853917Z mysqld_safe Logging to '/data/mysql.err'.
2021-11-10T03:55:09.884127Z mysqld_safe Starting mysqld daemon with databases from /data/data
5.초기 비밀번호 확인
[root@mysql8 bin]# cat /data/mysql.err | grep temp
2021-11-10T03:54:42.907613Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: Zm2l=qts#!95
6.DB Connect
[root@mysql8 bin]# /data/mysql/bin/mysql -uroot -p
Enter password: Zm2l=qts#!95
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.22-commercial
Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
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 Root 비밀번호 변경
- 초기에 root 비밀번호를 변경하지않으면 Query를 실행할수없기 때문에 root 비밀번호 수정해준다.
mysql> show databases;
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
1.root 비밀번호 수정
mysql> alter user 'root'@'localhost' identified by 'root';
Query OK, 0 rows affected (0.01 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
2.바뀐 비밀번호로 Connect
[root@mysql8 bin]# /data/mysql/bin/mysql -uroot -proot
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 8.0.22-commercial MySQL Enterprise Server - Commercial
Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
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.
3.Query 실행
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.01 sec)