MySQL Install Guide

MySQL 安装指引

安装

APT

# 安装官方 APT 源
wget -c https://repo.mysql.com/mysql-apt-config_0.8.13-1_all.deb
sudo dpkg -i mysql-apt-config_0.8.13-1_all.deb

# 重配 APT 源关联版本
sudo dpkg-reconfigure mysql-apt-config

# 安装 MySQL
sudo apt install mysql-community-server

YUM

升级

升级前需关闭服务器快关功能,以清空 redo 日志。

SET GLOBAL innodb_fast_shutdown = 0;

花絮

brew(Ubuntu)

默认无 Linux 下启动配置。

$ brew install mysql             
Updating Homebrew...
==> Installing dependencies for mysql: patchelf, openssl@1.1, zlib, gmp, isl, mpfr, libmpc, gcc@6, protobuf, ncurses, libedit and gcc@7
==> Installing mysql dependency: patchelf
==> Downloading https://linuxbrew.bintray.com/bottles/patchelf-0.10.x86_64_linux.bottle.tar.gz
==> Downloading from https://akamai.bintray.com/98/988b224305ff3fecadf9bbf5fbe1b18061077be6c896935b2cef29298526f5b8?__gda__=exp=1579501174~hmac=99d111c3c2b6e2c7eb98ef5b3aa606f925a6ee8d9ba06b3ccb8
######################################################################## 100.0%
==> Pouring patchelf-0.10.x86_64_linux.bottle.tar.gz
🍺  /home/linuxbrew/.linuxbrew/Cellar/patchelf/0.10: 8 files, 921.5KB
==> Installing mysql dependency: openssl@1.1
==> Downloading https://linuxbrew.bintray.com/bottles/openssl@1.1-1.1.1d_1.x86_64_linux.bottle.tar.gz
==> Downloading from https://akamai.bintray.com/01/010a4e5257eb685ac700f495208bed1e05155663f8083ab6ab2e4a91ef69c1cd?__gda__=exp=1579501187~hmac=6bfbc57a2623ab9518984e820365cf6ede14865b9b3da6b3b84
######################################################################## 100.0%
==> Pouring openssl@1.1-1.1.1d_1.x86_64_linux.bottle.tar.gz
==> Downloading https://curl.haxx.se/ca/cacert-2019-10-16.pem
######################################################################## 100.0%
==> Caveats
A CA file has been bootstrapped using certificates from the system
keychain. To add additional certificates, place .pem files in
  /home/linuxbrew/.linuxbrew/etc/openssl@1.1/certs

and run
  /home/linuxbrew/.linuxbrew/opt/openssl@1.1/bin/c_rehash

openssl@1.1 is keg-only, which means it was not symlinked into /home/linuxbrew/.linuxbrew,
because this is an alternate version of another formula.

If you need to have openssl@1.1 first in your PATH run:
  echo 'export PATH="/home/linuxbrew/.linuxbrew/opt/openssl@1.1/bin:$PATH"' >> ~/.zshrc

For compilers to find openssl@1.1 you may need to set:
  export LDFLAGS="-L/home/linuxbrew/.linuxbrew/opt/openssl@1.1/lib"
  export CPPFLAGS="-I/home/linuxbrew/.linuxbrew/opt/openssl@1.1/include"

==> Summary
🍺  /home/linuxbrew/.linuxbrew/Cellar/openssl@1.1/1.1.1d_1: 7,985 files, 21.2MB
==> Installing mysql dependency: zlib
==> Downloading https://linuxbrew.bintray.com/bottles/zlib-1.2.11.x86_64_linux.bottle.tar.gz
######################################################################## 100.0%
==> Pouring zlib-1.2.11.x86_64_linux.bottle.tar.gz
🍺  /home/linuxbrew/.linuxbrew/Cellar/zlib/1.2.11: 12 files, 424KB
==> Installing mysql dependency: gmp
==> Downloading https://linuxbrew.bintray.com/bottles/gmp-6.1.2_3.x86_64_linux.bottle.1.tar.gz
==> Downloading from https://akamai.bintray.com/a2/a21f68e8df094a2bccca845911eae1cf52bdefd19ca53cfd04aacf2a8112ece9?__gda__=exp=1579501223~hmac=450b62f0aba942c3e8a7777de9d8d385ea1736ee4b36aa76994
######################################################################## 100.0%
==> Pouring gmp-6.1.2_3.x86_64_linux.bottle.1.tar.gz
🍺  /home/linuxbrew/.linuxbrew/Cellar/gmp/6.1.2_3: 20 files, 3.8MB
==> Installing mysql dependency: isl
==> Downloading https://linuxbrew.bintray.com/bottles/isl-0.22.x86_64_linux.bottle.tar.gz
==> Downloading from https://akamai.bintray.com/07/07df0023ff3c6b9f545258564ac58066b4bc9f5370c83d66ba3e2c95f5149fd5?__gda__=exp=1579501229~hmac=34ae80236c57be301a12f1853aa5a30f3790e2b9fc02176222f
######################################################################## 100.0%
==> Pouring isl-0.22.x86_64_linux.bottle.tar.gz
🍺  /home/linuxbrew/.linuxbrew/Cellar/isl/0.22: 74 files, 6.4MB
==> Installing mysql dependency: mpfr
==> Downloading https://linuxbrew.bintray.com/bottles/mpfr-4.0.2.x86_64_linux.bottle.tar.gz
==> Downloading from https://akamai.bintray.com/cf/cffaa9976a516130ac5b979eae7bdd62180ed8924bb52bf0b30935174b1cbab0?__gda__=exp=1579501238~hmac=9d14b6209c1c1bb5da1688ce7eb3972fb9bde0cab971506ec05
######################################################################## 100.0%
==> Pouring mpfr-4.0.2.x86_64_linux.bottle.tar.gz
🍺  /home/linuxbrew/.linuxbrew/Cellar/mpfr/4.0.2: 29 files, 5.2MB
==> Installing mysql dependency: libmpc
==> Downloading https://linuxbrew.bintray.com/bottles/libmpc-1.1.0.x86_64_linux.bottle.tar.gz
==> Downloading from https://akamai.bintray.com/b3/b31648a86228a042aaa8e7d58faba7859059910a427f9ef4211b06bd9152f8c2?__gda__=exp=1579501248~hmac=0b7e1fa7c1e2c0b8249f35f42007f6a2ee889a59d0b00331a30
######################################################################## 100.0%
==> Pouring libmpc-1.1.0.x86_64_linux.bottle.tar.gz
🍺  /home/linuxbrew/.linuxbrew/Cellar/libmpc/1.1.0: 13 files, 1.5MB
==> Installing mysql dependency: gcc@6
==> Downloading https://linuxbrew.bintray.com/bottles/gcc@6-6.5.0_4.x86_64_linux.bottle.tar.gz
==> Downloading from https://akamai.bintray.com/d6/d67445571d72bd8696dfb4a019b3204be46e6705a7d8ed1113ed02887303c66a?__gda__=exp=1579501255~hmac=182d26c506ebca33abdb0d287df277c35696e833a97aeb6255a
######################################################################## 100.0%
==> Pouring gcc@6-6.5.0_4.x86_64_linux.bottle.tar.gz
==> Creating the GCC specs file: /home/linuxbrew/.linuxbrew/Cellar/gcc@6/6.5.0_4/lib/gcc/6/gcc/x86_64-pc-linux-gnu/6.5.0/specs
🍺  /home/linuxbrew/.linuxbrew/Cellar/gcc@6/6.5.0_4: 1,396 files, 190.7MB
==> Installing mysql dependency: protobuf
==> Downloading https://linuxbrew.bintray.com/bottles/protobuf-3.11.2.x86_64_linux.bottle.tar.gz
==> Downloading from https://akamai.bintray.com/a8/a84b223cfd1fa2adc1336afb7a11a8bc22f42163766ae55905e04bdb095c81a8?__gda__=exp=1579501368~hmac=944693ce5d279732c6dd7137db8aadf170c688145e274f25a9c
######################################################################## 100.0%
==> Pouring protobuf-3.11.2.x86_64_linux.bottle.tar.gz
Warning: protobuf dependency gmp was built with a different C++ standard
library (libstdc++ from gcc-5). This may cause problems at runtime.
🍺  /home/linuxbrew/.linuxbrew/Cellar/protobuf/3.11.2: 272 files, 30.2MB
==> Installing mysql dependency: ncurses
==> Downloading https://linuxbrew.bintray.com/bottles/ncurses-6.1.x86_64_linux.bottle.tar.gz
==> Downloading from https://akamai.bintray.com/5e/5eb929e69e3a2b71c2161551825fd16146efc164ab7dbea25d2a5b73b51cd1cb?__gda__=exp=1579501384~hmac=ae5a856d540dc0fd363859d3bf740f845e69499c11ce3e87f11
######################################################################## 100.0%
==> Pouring ncurses-6.1.x86_64_linux.bottle.tar.gz
🍺  /home/linuxbrew/.linuxbrew/Cellar/ncurses/6.1: 3,856 files, 15.4MB
==> Installing mysql dependency: libedit
==> Downloading https://linuxbrew.bintray.com/bottles/libedit-20191231-3.1.x86_64_linux.bottle.tar.gz
==> Downloading from https://akamai.bintray.com/e9/e95fee11c5e2e861388bfe1ca575a9d845610cd41aaac23244ce841f02bf6fff?__gda__=exp=1579501399~hmac=9330c12a6988cd9b775d12f04094d3acc61a5eaec49e2f4ca58
######################################################################## 100.0%
==> Pouring libedit-20191231-3.1.x86_64_linux.bottle.tar.gz
🍺  /home/linuxbrew/.linuxbrew/Cellar/libedit/20191231-3.1: 56 files, 774.9KB
==> Installing mysql dependency: gcc@7
==> Downloading https://linuxbrew.bintray.com/bottles/gcc@7-7.5.0_1.x86_64_linux.bottle.tar.gz
==> Downloading from https://akamai.bintray.com/3f/3fd23c5d356570f2cc08bfc106ca050c3daa668e497eca794d3b93a38a440571?__gda__=exp=1579501406~hmac=c2f813b93b158b4200e51653dde575d52f7fa35909220d51e0f
######################################################################## 100.0%
==> Pouring gcc@7-7.5.0_1.x86_64_linux.bottle.tar.gz
==> Creating the GCC specs file: /home/linuxbrew/.linuxbrew/Cellar/gcc@7/7.5.0_1/lib/gcc/7/gcc/x86_64-pc-linux-gnu/7.5.0/specs
🍺  /home/linuxbrew/.linuxbrew/Cellar/gcc@7/7.5.0_1: 1,434 files, 200.3MB
==> Installing mysql
==> Downloading https://linuxbrew.bintray.com/bottles/mysql-8.0.19.x86_64_linux.bottle.tar.gz
==> Downloading from https://akamai.bintray.com/b3/b3bf85d99a4600e1111f2c107b583253c5ae654c61290fd7bf106947599ddba0?__gda__=exp=1579501517~hmac=4ef105484d041153b523458e43a7e2fca05499717e40a3b930e
######################################################################## 100.0%
==> Pouring mysql-8.0.19.x86_64_linux.bottle.tar.gz
Warning: mysql dependency gmp was built with a different C++ standard
library (libstdc++ from gcc-5). This may cause problems at runtime.
==> /home/linuxbrew/.linuxbrew/Cellar/mysql/8.0.19/bin/mysqld --initialize-insecure --user=ma3310 --basedir=/home/linuxbrew/.linuxbrew/Cellar/mysql/8.0.19 --datadir=/home/linuxbrew/.linuxbrew/var
==> Caveats
We've installed your MySQL database without a root password. To secure it run:
    mysql_secure_installation

MySQL is configured to only allow connections from localhost by default

To connect run:
    mysql -uroot

Warning: mysql provides a launchd plist which can only be used on macOS!
You can manually execute the service instead with:
  mysql.server start
==> Summary
🍺  /home/linuxbrew/.linuxbrew/Cellar/mysql/8.0.19: 289 files, 241MB
==> Caveats
==> openssl@1.1
A CA file has been bootstrapped using certificates from the system
keychain. To add additional certificates, place .pem files in
  /home/linuxbrew/.linuxbrew/etc/openssl@1.1/certs

and run
  /home/linuxbrew/.linuxbrew/opt/openssl@1.1/bin/c_rehash

openssl@1.1 is keg-only, which means it was not symlinked into /home/linuxbrew/.linuxbrew,
because this is an alternate version of another formula.

If you need to have openssl@1.1 first in your PATH run:
  echo 'export PATH="/home/linuxbrew/.linuxbrew/opt/openssl@1.1/bin:$PATH"' >> ~/.zshrc

For compilers to find openssl@1.1 you may need to set:
  export LDFLAGS="-L/home/linuxbrew/.linuxbrew/opt/openssl@1.1/lib"
  export CPPFLAGS="-I/home/linuxbrew/.linuxbrew/opt/openssl@1.1/include"

==> mysql
We've installed your MySQL database without a root password. To secure it run:
    mysql_secure_installation

MySQL is configured to only allow connections from localhost by default

To connect run:
    mysql -uroot

Warning: mysql provides a launchd plist which can only be used on macOS!
You can manually execute the service instead with:
  mysql.server start
Author: njun
njun's picture
Updated: 2020/01/20