ÃֽŠ°Ô½Ã±Û(DB)
2018.10.18 / 14:37

Ubuntu 18.04 : MySQL 8.0.12 ÄÄÆÄÀÏ, ¼³Ä¡

hanulbit
Ãßõ ¼ö 200

Ãâó

¸®´ª½º Á¤º¸ Á¶È¸

Ãâó : ¸®´ª½º Á¾·ù È®ÀÎ, ¸®´ª½º ¹öÀü È®ÀÎ - Á¦Å¸À§Å°

X
user@localhost:~

[user@localhost]$ cat /etc/*-release | uniq
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=18.04
DISTRIB_CODENAME=bionic
DISTRIB_DESCRIPTION="Ubuntu 18.04.1 LTS"
NAME="Ubuntu"
VERSION="18.04.1 LTS (Bionic Beaver)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 18.04.1 LTS"
VERSION_ID="18.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=bionic
UBUNTU_CODENAME=bionic

¸®´ª½º ºñÆ® È®ÀÎ

Ãâó : ¸®´ª½º 32ºñÆ® 64ºñÆ® È®ÀÎ - Á¦Å¸À§Å°

X
user@localhost:~

[user@localhost]$ getconf LONG_BIT
64

°ü·ÃÆÐÅ°Áö ¼³Ä¡

X
user@localhost:~

[user@localhost]$ sudo apt-get update
[user@localhost]$ sudo apt-get install gcc g++ libncurses5-dev libxml2-dev openssl libssl-dev curl libcurl4-openssl-dev libjpeg-dev libpng-dev libfreetype6-dev libsasl2-dev autoconf libncurses5-dev

cmake ¼³Ä¡

X
user@localhost:~

[user@localhost]$ sudo apt-get install cmake

MySQL °èÁ¤ ¸¸µé±â

X
user@localhost:~

[user@localhost]$ sudo groupadd mysql
[user@localhost]$ sudo useradd -g mysql -s /bin/bash -m mysql

MySQL ¼Ò½º ´Ù¿î·Îµå

X
user@localhost:~

[user@localhost]$ wget https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-8.0.12.tar.gz

MySQL ¼Ò½º ¾ÐÃàÇ®±â

X
user@localhost:~

[user@localhost]$ tar xvf mysql-8.0.12.tar.gz

MySQL ÄÄÆÄÀÏ ¹× ¼³Ä¡

X
user@localhost:~

[user@localhost]$ cd mysql-8.0.12/
[user@localhost]$ sudo cmake \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_DATADIR=/usr/local/mysql/data \
-DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock \
-DSYSCONFDIR=/usr/local/mysql \
-DMYSQL_TCP_PORT=3306 \
-DMYSQL_USER=mysql \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_EXTRA_CHARSETS=all \
-DENABLED_LOCAL_INFILE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_ARCHIVE_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DDOWNLOAD_BOOST=1 -DWITH_BOOST=/usr/local/mysql/boost
[user@localhost]$ sudo make
[user@localhost]$ sudo make install

MySQL ¼³Ä¡ µð·ºÅ丮 mysql °èÁ¤À¸·Î ±ÇÇÑ ¼öÁ¤

X
user@localhost:~

[user@localhost]$ sudo chown -R mysql:mysql /usr/local/mysql

ȯ°æ¼³Á¤

X
user@localhost:~

[user@localhost]$ vi /usr/local/mysql/my.cnf


[mysqld]
bind-address=0.0.0.0
port=3306
basedir=/usr/local/mysql
datadir=/usr/local/mysql/data
# pid-file=/usr/local/mysql/mysqld.pid
# log_error=/usr/local/mysql/mysql_error.log
# lc-messages-dir=/usr/local/mysql/share

init_connect=SET collation_connection = utf8_general_ci
init_connect=SET NAMES utf8
character-set-server=utf8
collation-server=utf8_general_ci
# table_cache=1024
max_connections=2048
max_user_connections=500
max_connect_errors=10000
wait_timeout=300
# query_cache_type = 1
# query_cache_size = 128M
# query_cache_limit = 5M
slow_query_log
long_query_time=3
max_allowed_packet=16M
sort_buffer_size = 2M
# skip-innodb
skip-name-resolve
# sql_mode = STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION

[mysql]
default-character-set=utf8

[client]
default-character-set=utf8

MySQL µ¥ÀÌÅͺ£À̽º ÃʱâÈ­ (mysql °èÁ¤À¸·Î ½ÇÇà)

X
user@localhost:~

[user@localhost]$ cd /usr/local/mysql
[user@localhost]$ bin/mysqld --defaults-file=/usr/local/mysql/my.cnf --initialize --console --user=mysql --datadir=/usr/local/mysql/data --basedir=/usr/local/mysql
2018-10-03T03:17:05.650419Z 0 [System] [MY-013169] [Server] /usr/local/mysql/bin/mysqld (mysqld 8.0.12) initializing of server in progress as process 5644
2018-10-03T03:17:08.797874Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: q<chLu;Cy2yY
2018-10-03T03:17:10.426427Z 0 [System] [MY-013170] [Server] /usr/local/mysql/bin/mysqld (mysqld 8.0.12) initializing of server has completed

MySQL Á¾·á (ÇÁ·Î¼¼½º°¡ Á¸ÀçÇÏ´Â °æ¿ì)

X
user@localhost:~

[user@localhost]$ bin/mysqld stop
2018-10-03T01:59:45.345444Z 0 [System] [MY-010116] [Server] /usr/local/mysql/bin/mysqld (mysqld 8.0.12) starting as process 3662
2018-10-03T01:59:45.756978Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
2018-10-03T01:59:45.761934Z 0 [ERROR] [MY-010147] [Server] Too many arguments (first extra is 'stop').
2018-10-03T01:59:45.761967Z 0 [Warning] [MY-010952] [Server] The privilege system failed to initialize correctly. If you have upgraded your server, make sure you're executing mysql_upgrade to correct the issue.
2018-10-03T01:59:45.762056Z 0 [ERROR] [MY-010119] [Server] Aborting
2018-10-03T01:59:47.444146Z 0 [System] [MY-010910] [Server] /usr/local/mysql/bin/mysqld: Shutdown complete (mysqld 8.0.12)  Source distribution.

root ¾ÏÈ£ ÃʱâÈ­

X
user@localhost:~

[user@localhost]$ bin/mysqld_safe --skip-grant-tables &
[1] 3745
mysql@bluesanta-ubuntu:/usr/local/mysql$ 2018-10-03T03:20:12.286866Z mysqld_safe Logging to '/usr/local/mysql/data/bluesanta-ubuntu.err'.
2018-10-03T03:20:12.311924Z mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data


mysql@bluesanta-ubuntu:/usr/local/mysql$ bin/mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 7
Server version: 8.0.12 Source distribution

Copyright (c) 2000, 2018, 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> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.03 sec)

mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'sql';
Query OK, 0 rows affected (0.08 sec)

mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.01 sec)

mysql> quit
Bye

MySQL ¼­ºñ½º µî·Ï

¼­ºñ½º mysqld ÆÄÀÏ º¹»ç

X
user@localhost:~

[user@localhost]$ sudo cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld

mysqld ¼öÁ¤

X
user@localhost:~

[user@localhost]$ sudo vi /etc/init.d/mysqld

mysqldÆÄÀÏÀ» ¿­¾î¼­ basedir¿¡ mysqlÀÌ ¼³Ä¡µÈ µð·ºÅ丮¿Í µ¥ÀÌÅÍ µð·ºÅ丮(datadir)¸¦ ¼³Á¤ÇÑ´Ù.

basedir=/usr/local/mysql
datadir=/usr/local/mysql/data

mysqld ¼­ºñ½º µî·Ï

X
user@localhost:~

[user@localhost]$ sudo update-rc.d mysqld defaults
 Adding system startup for /etc/init.d/mysqld ...
   /etc/rc0.d/K20mysqld -> ../init.d/mysqld
   /etc/rc1.d/K20mysqld -> ../init.d/mysqld
   /etc/rc6.d/K20mysqld -> ../init.d/mysqld
   /etc/rc2.d/S20mysqld -> ../init.d/mysqld
   /etc/rc3.d/S20mysqld -> ../init.d/mysqld
   /etc/rc4.d/S20mysqld -> ../init.d/mysqld
   /etc/rc5.d/S20mysqld -> ../init.d/mysqld

mysqld ¼­ºñ½º ½ÇÇà

X
user@localhost:~

[user@localhost]$ sudo systemctl start mysqld.service
[user@localhost]$ sudo systemctl status mysqld.service
¡Ü mysqld.service - LSB: start and stop MySQL
   Loaded: loaded (/etc/init.d/mysqld; generated)
   Active: active (running) since Wed 2018-10-03 11:58:26 KST; 32s ago
     Docs: man:systemd-sysv-generator(8)
  Process: 4863 ExecStop=/etc/init.d/mysqld stop (code=exited, status=0/SUCCESS)
  Process: 4887 ExecStart=/etc/init.d/mysqld start (code=exited, status=0/SUCCESS)
    Tasks: 38 (limit: 4915)
   CGroup: /system.slice/mysqld.service
           ¦§¦¡4895 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/usr/local/mysql/data --pid-file=/usr/local/mysql/data/bluesanta-ubuntu.pid
           ¦¦¦¡4982 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --plugin-dir=/usr/local/mysql/lib/plugin --user=mysq
 
10¿ù 03 11:58:25 bluesanta-ubuntu systemd[1]: Starting LSB: start and stop MySQL...
10¿ù 03 11:58:25 bluesanta-ubuntu mysqld[4887]: Starting MySQL
10¿ù 03 11:58:26 bluesanta-ubuntu mysqld[4887]: . *
10¿ù 03 11:58:26 bluesanta-ubuntu systemd[1]: Started LSB: start and stop MySQL.
[user@localhost]$ sudo systemctl stop mysqld.service

ERROR 1820 (HY000) ¿À·ù ÇØ°á

mysql> select 1;
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
mysql> SET PASSWORD = PASSWORD('sql');
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql$gt; select 1;
+---+
| 1 |
+---+
| 1 |
+---+
1 row in set (0.00 sec)

mysql>

»ç¿ëÀÚ Ãß°¡

mysql> create user 'user1'@'%' identified by 'userpw';
mysql> grant all privileges on *.* to 'user1'@'%' with grant option;
mysql> flush privileges;

»ç¿ëÀÚ Ãß°¡

create user 'terecal'@'%' identified by '****';
GRANT ALL privileges ON terecal_db.* TO 'terecal'@'%';
flush privileges;



Ãâó: http://bluexmas.tistory.com/869?category=130687 [ÆĶõÅ©¸®½º¸¶½º]