2023년 4월 30일 일요일

[MySQL8] Ubuntu 20.04 에 MySQL8.0.32 수동설치 방법

 $ apt-get update 

$ apt-get install cmake 

$ apt-get install make 

$ apt-get install gcc 

$ apt-get install g++ 

$ apt-get install libssl-dev 

$ apt-get install libboost-all-dev 

$ apt-get install libncurses5-dev libncursesw5-dev     //$ apt-get install libncurses6-dev libncursesw6-dev

$ apt-get install perl

$ apt-get install pkg-config


MySQL 다운로드

wget https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-8.0.32.tar.gz


tar xvfz mysql-8.0.32.tar.gz


wget https://boostorg.jfrog.io/artifactory/main/release/1.77.0/source/boost_1_77_0.tar.bz2


tar -xvf boost_1_77_0.tar.bz2






cmake  ..  -DCMAKE_INSTALL_PREFIX=/home/mysql -DMYSQL_DATADIR=/home/mysql/data -DMYSQL_UNIX_ADDR=/home/mysql/mysql.sock -DMYSQL_TCP_PORT=3306 -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci   -DSYSCONFDIR=/home/mysql/etc  -DWITH_EXTRA_CHARSETS=all  -DWITH_INNOBASE_STORAGE_ENGINE=1  -DWITH_ARCHIVE_STORAGE_ENGINE=1  -DWITH_BLACKHOLE_STORAGE_ENGINE=1  -DDOWNLOAD_BOOST=1 -DWITH_BOOST=/home/mysql/boost_1_77_0



make


make install


$ vi /home/mysql/etc/my.cnf


[mysqld]

#transaction-isolation    = READ-COMMITTED

#pid-file        = /var/run/mysqld/mysqld.pid

#socket          = /var/run/mysqld/mysqld.sock

#datadir         = /home/mysql

#log-error       = /var/log/mysql/error.log

# By default we only accept connections from localhost

#bind-address   = 127.0.0.1

# Disabling symbolic-links is recommended to prevent assorted security risks

#symbolic-links=0

#basedir=/home/mysql

#datadir=/home/mysql/data

#bind-address    = 0.0.0.0

#port=3306

#character-set-server=utf8

#collation-server=utf8_general_ci

#init_connect = set collation_connection = utf8_general_ci

#init_connect = set names utf8

#lower_case_table_names = 1

#sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION

#default-time-zone='+9:00'

#key_buffer_size         = 16M

#max_allowed_packet      = 16M

#thread_stack            = 192K

#thread_cache_size       = 8

#sort_buffer_size=4M

#read_buffer_size=4M

#innodb_buffer_pool_size=8G

#max_heap_table_size = 2G

#tmp_table_size = 2G

#query_cache_limit       = 10M

#query_cache_size        = 32M

#expire_logs_days = 10

#max_binlog_size = 100M

#[mysql]

#default-character-set=utf8

#[client]

#default-character-set=utf8

#[mysqldump]

#default-character-set=utf8





-- fix


[mysqld]


basedir=/home/mysql

datadir=/home/mysql/data

bind-address    = 0.0.0.0

port=3306


lower_case_table_names = 1

sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION

default-time-zone='+9:00'


key_buffer_size         = 16M

max_allowed_packet      = 16M

thread_stack            = 192K

thread_cache_size       = 8


sort_buffer_size=4M

read_buffer_size=4M

innodb_buffer_pool_size=8G


max_heap_table_size = 2G

tmp_table_size = 2G



max_binlog_size = 100M







============================






$ groupadd mysql

$ useradd -r -g mysql -s /bin/false mysql

//Mysql 그룹 및 유저 생성하기


$ cd /home/mysql

$ mkdir mysql-files

//디렉토리 생성


$ chown -R mysql:mysql /home/mysql

$ chown mysql:mysql mysql-files

$ chmod 750 mysql-files

//권한부여하기 


$ /home/mysql/bin/mysqld --defaults-file=/home/mysql/etc/my.cnf  --initialize  --user=mysql  --basedir=/home/mysql  --datadir=/home/mysql/data

//임시 비밀번호 발급받기



$ /home/mysql/bin/mysqld_safe --defaults-file=/home/mysql/etc/my.cnf  --user=mysql & 

$ ps -ef | grep mysqld

$ /home/mysql/bin/mysql -u root -p

#Enter password : 위에서 생성된 임시 비밀번호 입력


CREATE DATABASE ems_db default CHARACTER SET UTF8;


ALTER USER 'root'@'localhost' IDENTIFIED BY '111111111';


use mysql;

create user 'root'@'%' identified by '111111111';

grant all privileges on *.* to 'root'@'%';

flush privileges;


create user 'ubuntu'@'localhost' identified by '111111111';

grant all privileges on *.* to 'ubuntu'@'localhost';

flush privileges;


create user 'ubuntu'@'localhost' identified by '111111111';

grant all privileges on *.* to 'ubuntu'@'%';

flush privileges;


select host, user from user;




$ sudo cp /home/mysql/support-files/mysql.server /etc/init.d/mysqld

mysqld 파일을 열어서 basedir 와 datadir 를 설정한다.


$ sudo vi /etc/init.d/mysqld




basedir=/home/mysql

datadir=/home/mysql/data





extra_args=""

if test -r "$basedir/etc/my.cnf"

then

  extra_args="-e $basedir/etc/my.cnf"

fi






=========




mysqld 서비스를 등록한다.


$ update-rc.d mysqld defaults

reboot로 다시 시작한 뒤 보면 서버시작 안 해도 서버 시작이 되어있음을 확인할 수 있다.


$ reboot 

$ ps -ef | grep mysqld



기타

+mysql 명령어


$ service mysql start

$ service mysql stop

$ service mysql restart $ service mysql status 

댓글 없음:

댓글 쓰기