#!/bin/bash
# mysql_8.0.28 version install
sudo apt-get remove --purge mysql*
# library install
sudo apt install libncurses5 -y
# create my.cnf
echo '[mysqld]
character-set-client-handshake=FALSE
init_connect="SET collation_connection = utf8_general_ci"
init_connect="SET NAMES utf8"
character-set-server = utf8
collation-server = utf8_general_ci
[mysqldump]
default-character-set = utf8
[mysql]
default-character-set = utf8
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
' >> /etc/my.cnf
# group & user add
sudo groupadd mysql
sudo useradd -r -g mysql -s /bin/false mysql
# mysql install file download & decompress
cd /usr/local
sudo wget https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-8.0.28-linux-glibc2.12-x86_64.tar.xz
sudo tar xvf mysql-8.0.28-linux-glibc2.12-x86_64.tar.xz
# symbolic link : mysql-version-os -> mysql
sudo ln -s /usr/local/mysql-8.0.28-linux-glibc2.12-x86_64 mysql
cd /var/run
sudo mkdir mysqld
sudo chown mysql mysqld
sudo chgrp mysql mysqld
# directory setting
cd /usr/local/mysql
sudo mkdir mysql-files sudo
sudo chown mysql:mysql mysql-files
sudo chmod 750 mysql-files
# mysql --initialize : installing
sudo bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
#ls >> /res2.txt
# create RSA files
sudo bin/mysql_ssl_rsa_setup
# mysql start & access
sudo bin/mysqld_safe --user=mysql &
sudo bin/mysql -uroot -p
# mysql_8.0.28 version install
sudo apt-get remove --purge mysql*
# library install
sudo apt install libncurses5 -y
# create my.cnf
echo '[mysqld]
character-set-client-handshake=FALSE
init_connect="SET collation_connection = utf8_general_ci"
init_connect="SET NAMES utf8"
character-set-server = utf8
collation-server = utf8_general_ci
[mysqldump]
default-character-set = utf8
[mysql]
default-character-set = utf8
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
' >> /etc/my.cnf
# group & user add
sudo groupadd mysql
sudo useradd -r -g mysql -s /bin/false mysql
# mysql install file download & decompress
cd /usr/local
sudo wget https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-8.0.28-linux-glibc2.12-x86_64.tar.xz
sudo tar xvf mysql-8.0.28-linux-glibc2.12-x86_64.tar.xz
# symbolic link : mysql-version-os -> mysql
sudo ln -s /usr/local/mysql-8.0.28-linux-glibc2.12-x86_64 mysql
cd /var/run
sudo mkdir mysqld
sudo chown mysql mysqld
sudo chgrp mysql mysqld
# directory setting
cd /usr/local/mysql
sudo mkdir mysql-files sudo
sudo chown mysql:mysql mysql-files
sudo chmod 750 mysql-files
# mysql --initialize : installing
sudo bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
#ls >> /res2.txt
# create RSA files
sudo bin/mysql_ssl_rsa_setup
# mysql start & access
sudo bin/mysqld_safe --user=mysql &
sudo bin/mysql -uroot -p
임시비밀번호발급 후 로그를 통해 임시비밀번호로 mysql에 접속하기.
mysqld.log에 mysql의 로그가 기록된다.
Mysql이 설치되면 다음과 같은 것들이 출력된다.
[System] [MY-013169] [Server] /usr/local/mysql-8.0.28-linux-glibc2.12-x86_64/bin/mysqld (mysqld 8.0.28) initializing of server in progress as process 7319
[Warning] [MY-013242] [Server] --character-set-server: 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous.
[Warning] [MY-013244] [Server] --collation-server: 'utf8_general_ci' is a collation of the deprecated character set UTF8MB3. Please consider using UTF8MB4 with an appropriate collation instead.
[System] [MY-013576] [InnoDB] InnoDB initialization has started.
[System] [MY-013577] [InnoDB] InnoDB initialization has ended.
[Note] [MY-010454] [Server] A temporary password is generated for root@localhost: >z8Vo5Flyean
[Note][MY-010454] [Server] A temporary password is generated for root@localhost: >z8Vo5Flyean
맨 마지막에 임시비밀번호가 나타난다.
2022-03-06T15:04:00.025407Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2022-03-06T15:04:00.192596Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2022-03-06T15:04:00.379440Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
2022-03-06T15:04:00.379487Z 0 [System] [MY-013602] [Server] Channel mysql_main configured to support TLS. Encrypted connections are now supported for this channel.
2022-03-06T15:04:00.398600Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Bind-address: '::' port: 33060, socket: /tmp/mysqlx.sock
2022-03-06T15:04:00.399227Z 0 [System] [MY-010931] [Server] /usr/local/mysql-8.0.28-linux-glibc2.12-x86_64/bin/mysqld: ready for connections. Version: '8.0.28' socket: '/tmp/mysql.sock' port: 3306 MySQL Community Server - GPL.
my.cnf에 로그가 저장될 경로를 지정하고 그 로그를 확인해보면
[System]이나 [Error] 태그를 가진 로그들은 기록되지만
임시비밀번호 같은 [Note] 태그를 가진 것들이 기록되지 않고 있다.
sudo sh /home/vagrant/**.sh로 실행해야 정상적으로 my.cnf 생성
#!/bin/bash
# mysql_8.0.28 version install
sudo apt-get remove --purge mysql*
# library install
sudo apt install libncurses5 -y
# group & user add
sudo groupadd mysql
sudo useradd -r -g mysql -s /bin/false mysql
# mysql install file download & decompress
cd /home/ubuntu/
sudo mkdir db
cd db
sudo wget https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-8.0.28-linux-glibc2.12-x86_64.tar.xz
sudo tar xvf mysql-8.0.28-linux-glibc2.12-x86_64.tar.xz
# symbolic link : mysql-version-os -> mysql
sudo ln -s /home/ubuntu/db/mysql-8.0.28-linux-glibc2.12-x86_64 mysql
# create my.cnf
echo '[mysqld]
character-set-client-handshake=FALSE
init_connect="SET collation_connection = utf8_general_ci"
init_connect="SET NAMES utf8"
character-set-server = utf8
collation-server = utf8_general_ci
datadir=/home/ubuntu/db/mysql/data
[mysqldump]
default-character-set = utf8
[mysql]
default-character-set = utf8
[mysqld_safe]
log-error=/var/log/mysqld.log
general_log = ON
general_log_file = /var/log/general_mysql.log
log-bin=/var/log/mysql/mysql_bin.log
pid-file=/var/run/mysqld/mysqld.pid
' >> /home/ubuntu/db/mysql/my.cnf
cd /var/run
sudo mkdir mysqld
sudo chown mysql mysqld
sudo chgrp mysql mysqld
# directory setting
cd /home/ubuntu/db/mysql
sudo mkdir mysql-files
sudo chown mysql:mysql mysql-files
sudo chmod 750 mysql-files
sudo mkdir data
sudo chown mysql:mysql data
# mysql --initialize : installin
sudo bin/mysqld --initialize --user=mysql --basedir=/home/ubuntu/db/mysql --datadir=/home/ubuntu/db/mysql/data > /install_mysql.log
#sudo bin/mysqld --initialize --user=mysql
# create RSA files
sudo bin/mysql_ssl_rsa_setup --datadir=/home/ubuntu/db/mysql/data
#sudo bin/mysql --defaults-file=/home/ubuntu/db/mysql/my.cnf
# mysql start & access
sudo bin/mysqld_safe --user=mysql &
sudo bin/mysql -uroot -p
[Note][MY-010454] [Server] A temporary password is generated for root@localhost: 27.YTTLp&Ke_
2022-03-07T16:03:52.888823Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2022-03-07T16:03:53.073150Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
2022-03-07T16:03:53.073199Z 0 [System] [MY-013602] [Server] Channel mysql_main configured to support TLS. Encrypted connections are now supported for this channel.
2022-03-07T16:03:53.097055Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Bind-address: '::' port: 33060, socket: /tmp/mysqlx.sock
2022-03-07T16:03:53.097081Z 0 [System] [MY-010931] [Server] /home/ubuntu/db/mysql-8.0.28-linux-glibc2.12-x86_64/bin/mysqld: ready for connections. Version: '8.0.28' socket: '/tmp/mysql.sock' port: 3306 MySQL Community Server - GPL.
여전히 Note 태그는 mysqld.log에 기록되지 않음