How to install MySQL 8.0 to Linux mint 18.3

How to install MySQL 8.0 to Linux mint 18.3

  • Add sources
  • Update
  • view & Install
    • View available mysql installation packages
  • Connect to the Server
    • Create database
  • Grant user for Database
  • install mysql webbench

  前不久MySQL官方发布了 8.0版本,MySQL 8.0添加了很多不错的新特性,很值得以玩,这里讲解一下在Linux Mint 18.x上以apt方式安装MySQL。

Linux Mint 18.x兼容Ubuntu 16.04 LTS,所以该文章也适用于兼容Ubuntu 16.04 LTS版本的Linux 发行套件。

Add sources

  MySQL官方将MySQL软件源APT Repository配置制作成了mysql-apt-config_x.y-z_all.deb,所以我们这里下载并安装mysql-apt-config_0.8.13-1_all.deb以便添加软件源。

lwk@qwfys ~/Downloads/Chromium $ wget -c https://dev.mysql.com/get/mysql-apt-config_0.8.13-1_all.deb
--2018-06-04 23:12:13--  https://dev.mysql.com/get/mysql-apt-config_0.8.13-1_all.deb
Resolving dev.mysql.com (dev.mysql.com)... 137.254.60.11
Connecting to dev.mysql.com (dev.mysql.com)|137.254.60.11|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://repo.mysql.com//mysql-apt-config_0.8.13-1_all.deb [following]
--2018-06-04 23:12:22--  https://repo.mysql.com//mysql-apt-config_0.8.13-1_all.deb
Resolving repo.mysql.com (repo.mysql.com)... 23.219.134.205
Connecting to repo.mysql.com (repo.mysql.com)|23.219.134.205|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 35970 (35K) [application/x-debian-package]
Saving to: ‘mysql-apt-config_0.8.13-1_all.deb’

mysql-apt-config_0.8.13-1_all.deb                           100%[=========================================================================================================================================>]  35.13K  --.-KB/s    in 0.06s   

2018-06-04 23:12:22 (628 KB/s) - ‘mysql-apt-config_0.8.13-1_all.deb’ saved [35970/35970]

  这里用dpkg -i命令安装该.deb软件包:

lwk@qwfys ~/Downloads/Chromium $ sudo dpkg -i mysql-apt-config_0.8.13-1_all.deb
(Reading database ... 301807 files and directories currently installed.)
Preparing to unpack mysql-apt-config_0.8.13-1_all.deb ...
Unpacking mysql-apt-config (0.8.10-1) over (0.8.10-1) ...
Setting up mysql-apt-config (0.8.10-1) ...
OK
lwk@qwfys ~/Downloads/Chromium $

  添加软件源的过程中,会弹出如下对话框,选择"OK",即可。
How to install MySQL 8.0 to Linux mint 18.3_第1张图片

  至此,软件源配置已经完成,这时会在目录/etc/apt/sources.list.d/中生成文件mysql.list

lwk@qwfys ~ $ ll /etc/apt/sources.list.d/
total 28
drwxr-xr-x 2 root root 4096 Jun  4 23:28 ./
drwxr-xr-x 6 root root 4096 Jun  4 22:13 ../
-rw-r--r-- 1 root root  500 Jun  4 23:28 mysql.list
-rw-r--r-- 1 root root  489 May 15 23:15 official-package-repositories.list
-rw-r--r-- 1 root root   62 May 15 04:12 pgdg.list
-rw-r--r-- 1 root root   65 Jun  2 22:41 sogoupinyin.list
-rw-r--r-- 1 root root   81 May 15 04:07 virtualbox.list
lwk@qwfys ~ $ cat /etc/apt/sources.list.d/mysql.list 
### THIS FILE IS AUTOMATICALLY CONFIGURED ###
# You may comment out entries below, but any other modifications may be lost.
# Use command 'dpkg-reconfigure mysql-apt-config' as root for modifications.
deb http://repo.mysql.com/apt/ubuntu/ xenial mysql-apt-config
deb http://repo.mysql.com/apt/ubuntu/ xenial mysql-8.0
deb http://repo.mysql.com/apt/ubuntu/ xenial mysql-tools
#deb http://repo.mysql.com/apt/ubuntu/ xenial mysql-tools-preview
deb-src http://repo.mysql.com/apt/ubuntu/ xenial mysql-8.0
lwk@qwfys ~ $ 

Update

  更新本地apt软件包缓存以便 进一步安装:

lwk@qwfys ~ $ apt update
Ign:1 http://mirrors.ustc.edu.cn/linuxmint sylvia InRelease
Hit:2 http://archive.ubuntukylin.com:10006/ubuntukylin xenial InRelease                                                                                                                                                                      
Hit:3 http://mirrors.ustc.edu.cn/ubuntu xenial InRelease                                                                                                                                                                                     
Hit:4 http://mirrors.ustc.edu.cn/ubuntu xenial-updates InRelease                                                                                                                                                                             
Hit:5 http://repo.mysql.com/apt/ubuntu xenial InRelease                                                                                                                                                                                      
Hit:6 http://mirrors.ustc.edu.cn/ubuntu xenial-backports InRelease                                                                                                                                                                   
Hit:7 http://download.virtualbox.org/virtualbox/debian xenial InRelease                                                                                                                                                              
Hit:8 http://mirrors.ustc.edu.cn/linuxmint sylvia Release                                                                                                                                                      
Hit:9 http://archive.canonical.com/ubuntu xenial InRelease                                                                                                                                                     
Hit:11 http://apt.postgresql.org/pub/repos/apt xenial-pgdg InRelease                           
Hit:12 http://security.ubuntu.com/ubuntu xenial-security InRelease       
Reading package lists... Done
Building dependency tree       
Reading state information... Done
All packages are up to date.
lwk@qwfys ~ $

view & Install

View available mysql installation packages

  安装前先用如下命令查询待安装的软件包的版本是否存在:

lwk@qwfys:~$ apt list |grep mysql

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

akonadi-backend-mysql/bionic,bionic 4:17.12.3-0ubuntu3 all
aolserver4-nsmysql/bionic 0.6-11 amd64
asterisk-mysql/bionic 1:13.18.3~dfsg-1ubuntu4 amd64
automysqlbackup/bionic,bionic 2.6+debian.4-1 all
bacula-common-mysql/bionic 9.0.6-1build1 amd64
bacula-director-mysql/bionic 9.0.6-1build1 amd64
cl-sql-mysql/bionic 6.7.0-1.1 amd64
courier-authlib-mysql/bionic-updates 0.68.0-4ubuntu0.1 amd64
cvm-mysql/bionic 0.97-0.1 amd64
dbconfig-mysql/bionic,bionic 2.0.9 all
dbf2mysql/bionic 1.14a-5.1 amd64
default-libmysqlclient-dev/bionic 1.0.4 amd64
default-libmysqld-dev/bionic 1.0.4 amd64
default-mysql-client/bionic,bionic 1.0.4 all
default-mysql-client-core/bionic,bionic 1.0.4 all
default-mysql-server/bionic,bionic 1.0.4 all
default-mysql-server-core/bionic,bionic 1.0.4 all
diaspora-installer-mysql/bionic,bionic 0.7.3.1+debian2ubuntu2 all
dovecot-mysql/bionic-updates,bionic-security 1:2.2.33.2-1ubuntu4.3 amd64
dpm-copy-server-mysql/bionic 1.10.0-2 amd64
dpm-name-server-mysql/bionic 1.10.0-2 amd64
dpm-server-mysql/bionic 1.10.0-2 amd64
dpm-srm-server-mysql/bionic 1.10.0-2 amd64
erlang-p1-mysql/bionic 1.0.4-2 amd64
freeradius-mysql/bionic-updates,bionic-security 3.0.16+dfsg-1ubuntu3.1 amd64
gmysqlcc/bionic 0.3.0-6 amd64
gnash-ext-mysql/bionic 0.8.11~git20160608-1.4 amd64
gnokii-smsd-mysql/bionic 0.6.31+dfsg-2ubuntu6 amd64
golang-github-go-sql-driver-mysql-dev/bionic,bionic 1.3-1 all
groonga-normalizer-mysql/bionic 1.1.1-4 amd64
homer-api-mysql/bionic 5.0.6+dfsg2-3 amd64
icinga2-ido-mysql/bionic 2.8.1-0ubuntu2 amd64
kamailio-mysql-modules/bionic 5.1.2-1ubuntu2 amd64
kexi-mysql-driver/bionic 1:3.1.0-2 amd64
lfc-server-mysql/bionic 1.10.0-2 amd64
libapache2-mod-log-sql-mysql/bionic 1.100-16.3 amd64
libaprutil1-dbd-mysql/bionic 1.6.1-2 amd64
libclass-dbi-mysql-perl/bionic,bionic 1.00-3 all
libcppdb-mysql0/bionic 0.3.1+dfsg-6 amd64
libcrypt-mysql-perl/bionic 0.04-6build3 amd64
libdatetime-format-mysql-perl/bionic,bionic 0.06-1 all
libdbd-mysql/bionic 0.9.0-5ubuntu2 amd64
libdbd-mysql-perl/bionic 4.046-1 amd64
libgda-5.0-mysql/bionic-updates 5.2.4-9ubuntu0.1 amd64
libkdb3-driver-mysql/bionic 3.1.0-2 amd64
libmysql++-dev/bionic 3.2.2+pristine-2ubuntu3 amd64
libmysql++-doc/bionic,bionic 3.2.2+pristine-2ubuntu3 all
libmysql++3v5/bionic 3.2.2+pristine-2ubuntu3 amd64
libmysql-cil-dev/bionic,bionic 6.4.3-4 all
libmysql-diff-perl/bionic,bionic 0.50-1 all
libmysql-java/bionic,bionic 5.1.45-1 all
libmysql-ocaml/bionic 1.2.1-1build1 amd64
libmysql-ocaml-dev/bionic 1.2.1-1build1 amd64
libmysql6.4-cil/bionic,bionic 6.4.3-4 all
libmysqlclient-dev/unknown 8.0.17-1ubuntu18.04 amd64
libmysqlclient20/bionic-updates,bionic-security 5.7.27-0ubuntu0.18.04.1 amd64
libmysqlclient21/unknown 8.0.17-1ubuntu18.04 amd64
libmysqlclient21-dbgsym/unknown 8.0.17-1ubuntu18.04 amd64
libmysqlcppconn-dev/unknown 8.0.17-1ubuntu18.04 amd64
libmysqlcppconn7/unknown 8.0.17-1ubuntu18.04 amd64
libmysqlcppconn7-dbgsym/unknown 8.0.17-1ubuntu18.04 amd64
libmysqlcppconn7v5/bionic 1.1.9-1 amd64
libmysqlcppconn8-1/unknown 8.0.15-1ubuntu18.04 amd64
libmysqlcppconn8-2/unknown 8.0.17-1ubuntu18.04 amd64
libmysqlcppconn8-2-dbgsym/unknown 8.0.17-1ubuntu18.04 amd64
libmysqld-dev/bionic-updates,bionic-security 5.7.27-0ubuntu0.18.04.1 amd64
libodb-mysql-2.4/bionic 2.4.0-3 amd64
libodb-mysql-dev/bionic 2.4.0-3 amd64
libopendbx1-mysql/bionic 1.4.6-11 amd64
libpam-mysql/bionic 0.8.0-1ubuntu2 amd64
libpocodatamysql50/bionic 1.8.0.1-1ubuntu4 amd64
libpreludedb7-mysql/bionic 4.1.0-1 amd64
libqt4-sql-mysql/bionic 4:4.8.7+dfsg-7ubuntu1 amd64
libqt5sql5-mysql/bionic-updates,bionic-security 5.9.5+dfsg-0ubuntu2.1 amd64
librdf-storage-mysql/bionic 1.0.17-1.1 amd64
libreoffice-mysql-connector/bionic-updates,bionic-security 1.0.2+LibO6.0.7-0ubuntu0.18.04.8 amd64
libsoci-mysql3.2v5/bionic 3.2.3-2ubuntu2 amd64
libtime-piece-mysql-perl/bionic,bionic 0.06-2 all
lighttpd-mod-authn-mysql/bionic-updates 1.4.45-1ubuntu3.18.04 amd64
lighttpd-mod-mysql-vhost/bionic-updates 1.4.45-1ubuntu3.18.04 amd64
lua-dbi-mysql/bionic 0.5.hg5ba1dd988961-4 amd64
lua-dbi-mysql-dbg/bionic 0.5.hg5ba1dd988961-4 amd64
lua-dbi-mysql-dev/bionic 0.5.hg5ba1dd988961-4 amd64
lua-sql-mysql/bionic 2.3.4-1 amd64
lua-sql-mysql-dev/bionic 2.3.4-1 amd64
mha4mysql-manager/bionic,bionic 0.55-1 all
mha4mysql-node/bionic,bionic 0.54-1 all
monodoc-mysql-manual/bionic,bionic 6.4.3-4 all
mysql-apt-config/unknown,unknown,now 0.8.13-1 all [installed]
mysql-client/unknown 8.0.17-1ubuntu18.04 amd64
mysql-client-5.7/bionic-updates,bionic-security 5.7.27-0ubuntu0.18.04.1 amd64
mysql-client-core-5.7/bionic-updates,bionic-security 5.7.27-0ubuntu0.18.04.1 amd64
mysql-common/unknown 8.0.17-1ubuntu18.04 amd64
mysql-community-client/unknown 8.0.17-1ubuntu18.04 amd64
mysql-community-client-core/unknown 8.0.17-1ubuntu18.04 amd64
mysql-community-client-core-dbgsym/unknown 8.0.17-1ubuntu18.04 amd64
mysql-community-client-dbgsym/unknown 8.0.17-1ubuntu18.04 amd64
mysql-community-server/unknown 8.0.17-1ubuntu18.04 amd64
mysql-community-server-core/unknown 8.0.17-1ubuntu18.04 amd64
mysql-community-server-core-dbgsym/unknown 8.0.17-1ubuntu18.04 amd64
mysql-community-server-debug/unknown 8.0.17-1ubuntu18.04 amd64
mysql-community-server-debug-dbgsym/unknown 8.0.17-1ubuntu18.04 amd64
mysql-community-test/unknown 8.0.17-1ubuntu18.04 amd64
mysql-community-test-dbgsym/unknown 8.0.17-1ubuntu18.04 amd64
mysql-community-test-debug/unknown 8.0.17-1ubuntu18.04 amd64
mysql-connector-java/unknown,unknown 8.0.17-1ubuntu18.04 all
mysql-connector-python/unknown,unknown 8.0.17-1ubuntu18.04 all
mysql-connector-python-cext/unknown 8.0.17-1ubuntu18.04 amd64
mysql-connector-python-cext-py3/unknown 8.0.17-1ubuntu18.04 amd64
mysql-connector-python-py3/unknown,unknown 8.0.17-1ubuntu18.04 all
mysql-router/unknown 8.0.17-1ubuntu18.04 amd64
mysql-router-community/unknown 8.0.17-1ubuntu18.04 amd64
mysql-router-community-dbgsym/unknown 8.0.17-1ubuntu18.04 amd64
mysql-router-community-dev/unknown 8.0.17-1ubuntu18.04 amd64
mysql-sandbox/bionic,bionic 3.2.05-1 all
mysql-server/unknown 8.0.17-1ubuntu18.04 amd64
mysql-server-5.7/bionic-updates,bionic-security 5.7.27-0ubuntu0.18.04.1 amd64
mysql-server-core-5.7/bionic-updates,bionic-security 5.7.27-0ubuntu0.18.04.1 amd64
mysql-shell/unknown 8.0.17-1ubuntu18.04 amd64
mysql-source-5.7/bionic-updates,bionic-security 5.7.27-0ubuntu0.18.04.1 amd64
mysql-testsuite/unknown 8.0.17-1ubuntu18.04 amd64
mysql-testsuite-5.7/bionic-updates,bionic-security 5.7.27-0ubuntu0.18.04.1 amd64
mysql-utilities/bionic,bionic 1.6.4-1 all
mysql-workbench/bionic 6.3.8+dfsg-1build3 amd64
mysql-workbench-community/unknown 8.0.17-1ubuntu18.04 amd64
mysql-workbench-data/bionic,bionic 6.3.8+dfsg-1build3 all
mysqltcl/bionic 3.052-2 amd64
mysqltuner/bionic,bionic 1.7.2-1 all
node-mysql/bionic,bionic 2.10.2-1 all
oar-server-mysql/bionic 2.5.7-3 amd64
oar-user-mysql/bionic 2.5.7-3 amd64
opendnssec-enforcer-mysql/bionic 1:2.1.3-0.2build1 amd64
opensips-mysql-module/bionic 2.2.2-3build4 amd64
parser3-mysql/bionic 10.7-2 amd64
pdns-backend-mysql/bionic 4.1.1-1 amd64
perdition-mysql/bionic 2.2-3ubuntu2 amd64
php-mdb2-driver-mysql/bionic,bionic 1.5.0b4-2 all
php-mysql/bionic,bionic 1:7.2+60ubuntu1 all
php7.2-mysql/bionic-updates,bionic-security 7.2.19-0ubuntu0.18.04.1 amd64
pike7.8-mysql/bionic 7.8.866-8.1 amd64
pike8.0-mysql/bionic 8.0.498-1build1 amd64
postfix-mysql/bionic-updates 3.3.0-1ubuntu0.2 amd64
postgresql-10-mysql-fdw/bionic 2.3.0-2 amd64
proftpd-mod-mysql/bionic 1.3.5e-1build1 amd64
prometheus-mysqld-exporter/bionic 0.9.0+ds-3 amd64
puppet-module-puppetlabs-mysql/bionic,bionic 3.10.0-1 all
pure-ftpd-mysql/bionic 1.0.46-1build1 amd64
python-mysql.connector/bionic,bionic 2.1.6-1 all
python-mysqldb/bionic 1.3.10-1build1 amd64
python-mysqldb-dbg/bionic 1.3.10-1build1 amd64
python-pymysql/bionic,bionic 0.8.0-1 all
python-pymysql-doc/bionic,bionic 0.8.0-1 all
python-testing.mysqld/bionic,bionic 1.4.0-2 all
python3-mysql.connector/bionic,bionic 2.1.6-1 all
python3-mysqldb/bionic 1.3.10-1build1 amd64
python3-mysqldb-dbg/bionic 1.3.10-1build1 amd64
python3-pymysql/bionic,bionic 0.8.0-1 all
python3-testing.mysqld/bionic,bionic 1.4.0-2 all
r-cran-rmysql/bionic 0.10.13-2 amd64
redmine-mysql/bionic,bionic 3.4.4-1 all
roundcube-mysql/bionic,bionic 1.3.6+dfsg.1-1 all
rsyslog-mysql/bionic 8.32.0-1ubuntu4 amd64
rt4-db-mysql/bionic,bionic 4.4.2-2 all
ruby-dataobjects-mysql/bionic 0.10.16-2ubuntu3 amd64
ruby-mysql2/bionic 0.4.10-0ubuntu5 amd64
tarantool-lts-mysql-module/bionic 1.5.5.37.g1687c02-1 amd64
tcl8.6-tdbc-mysql/bionic 1.0.6-1 amd64
tntdb-mysql4v5/bionic 1.3-4 amd64
ulogd2-mysql/bionic 2.0.5-5 amd64
voms-mysql-plugin/bionic 3.1.7-2 amd64
w1retap-mysql/bionic 1.4.4-3 amd64
zabbix-proxy-mysql/bionic 1:3.0.12+dfsg-1 amd64
zabbix-server-mysql/bionic 1:3.0.12+dfsg-1 amd64
lwk@qwfys:~$

  可以看到只要安装mysql-server包就可以安装MySQL 8.0了,为了方便后续通过 GUI工具进行管理,这里可以安装mysql workbench。

lwk@qwfys:~$ apt install mysql-server mysql-client 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  libaio1 libmecab2 mysql-common mysql-community-client mysql-community-client-core mysql-community-server mysql-community-server-core
Recommended packages:
  mecab-ipadic-utf8
The following NEW packages will be installed:
  libaio1 libmecab2 mysql-client mysql-common mysql-community-client mysql-community-client-core mysql-community-server mysql-community-server-core mysql-server
0 upgraded, 9 newly installed, 0 to remove and 0 not upgraded.
Need to get 20.5 MB of archives.
After this operation, 180 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://mirrors.ustc.edu.cn/ubuntu bionic-updates/main amd64 libaio1 amd64 0.3.110-5ubuntu0.1 [6,476 B]
Get:2 http://mirrors.ustc.edu.cn/ubuntu bionic/universe amd64 libmecab2 amd64 0.996-5 [257 kB]
Get:3 http://repo.mysql.com/apt/ubuntu bionic/mysql-8.0 amd64 mysql-common amd64 8.0.17-1ubuntu18.04 [84.6 kB]
Get:4 http://repo.mysql.com/apt/ubuntu bionic/mysql-8.0 amd64 mysql-community-client-core amd64 8.0.17-1ubuntu18.04 [1,528 kB]
Get:5 http://repo.mysql.com/apt/ubuntu bionic/mysql-8.0 amd64 mysql-community-client amd64 8.0.17-1ubuntu18.04 [2,538 kB]
Get:6 http://repo.mysql.com/apt/ubuntu bionic/mysql-8.0 amd64 mysql-client amd64 8.0.17-1ubuntu18.04 [81.2 kB]
Get:7 http://repo.mysql.com/apt/ubuntu bionic/mysql-8.0 amd64 mysql-community-server-core amd64 8.0.17-1ubuntu18.04 [15.9 MB]
Get:8 http://repo.mysql.com/apt/ubuntu bionic/mysql-8.0 amd64 mysql-community-server amd64 8.0.17-1ubuntu18.04 [92.3 kB]                                                                                                                     
Get:9 http://repo.mysql.com/apt/ubuntu bionic/mysql-8.0 amd64 mysql-server amd64 8.0.17-1ubuntu18.04 [81.2 kB]                                                                                                                               
Fetched 20.5 MB in 15s (1,399 kB/s)                                                                                                                                                                                                          
Preconfiguring packages ...
Selecting previously unselected package mysql-common.
(Reading database ... 324773 files and directories currently installed.)
Preparing to unpack .../0-mysql-common_8.0.17-1ubuntu18.04_amd64.deb ...
Unpacking mysql-common (8.0.17-1ubuntu18.04) ...
Selecting previously unselected package mysql-community-client-core.
Preparing to unpack .../1-mysql-community-client-core_8.0.17-1ubuntu18.04_amd64.deb ...
Unpacking mysql-community-client-core (8.0.17-1ubuntu18.04) ...
Selecting previously unselected package mysql-community-client.
Preparing to unpack .../2-mysql-community-client_8.0.17-1ubuntu18.04_amd64.deb ...
Unpacking mysql-community-client (8.0.17-1ubuntu18.04) ...
Selecting previously unselected package mysql-client.
Preparing to unpack .../3-mysql-client_8.0.17-1ubuntu18.04_amd64.deb ...
Unpacking mysql-client (8.0.17-1ubuntu18.04) ...
Selecting previously unselected package libaio1:amd64.
Preparing to unpack .../4-libaio1_0.3.110-5ubuntu0.1_amd64.deb ...
Unpacking libaio1:amd64 (0.3.110-5ubuntu0.1) ...
Selecting previously unselected package libmecab2:amd64.
Preparing to unpack .../5-libmecab2_0.996-5_amd64.deb ...
Unpacking libmecab2:amd64 (0.996-5) ...
Selecting previously unselected package mysql-community-server-core.
Preparing to unpack .../6-mysql-community-server-core_8.0.17-1ubuntu18.04_amd64.deb ...
Unpacking mysql-community-server-core (8.0.17-1ubuntu18.04) ...
Selecting previously unselected package mysql-community-server.
Preparing to unpack .../7-mysql-community-server_8.0.17-1ubuntu18.04_amd64.deb ...
Unpacking mysql-community-server (8.0.17-1ubuntu18.04) ...
Selecting previously unselected package mysql-server.
Preparing to unpack .../8-mysql-server_8.0.17-1ubuntu18.04_amd64.deb ...
Unpacking mysql-server (8.0.17-1ubuntu18.04) ...
Setting up mysql-common (8.0.17-1ubuntu18.04) ...
update-alternatives: using /etc/mysql/my.cnf.fallback to provide /etc/mysql/my.cnf (my.cnf) in auto mode
Setting up libmecab2:amd64 (0.996-5) ...
Setting up mysql-community-client-core (8.0.17-1ubuntu18.04) ...
Processing triggers for libc-bin (2.27-3ubuntu1) ...
Setting up libaio1:amd64 (0.3.110-5ubuntu0.1) ...
Processing triggers for man-db (2.8.3-2ubuntu0.1) ...
Setting up mysql-community-client (8.0.17-1ubuntu18.04) ...
Setting up mysql-client (8.0.17-1ubuntu18.04) ...
Setting up mysql-community-server-core (8.0.17-1ubuntu18.04) ...
Setting up mysql-community-server (8.0.17-1ubuntu18.04) ...
update-alternatives: using /etc/mysql/mysql.cnf to provide /etc/mysql/my.cnf (my.cnf) in auto mode
Created symlink /etc/systemd/system/multi-user.target.wants/mysql.service → /lib/systemd/system/mysql.service.
Setting up mysql-server (8.0.17-1ubuntu18.04) ...
Processing triggers for libc-bin (2.27-3ubuntu1) ...
lwk@qwfys:~$ 

至此安装完成,执行如下命令可以查看MySQL服务运行状态:

lwk@qwfys:~$ systemctl status mysql.service 
● mysql.service - MySQL Community Server
   Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
   Active: active (running) since Tue 2019-08-06 15:54:42 CST; 10min ago
     Docs: man:mysqld(8)
           http://dev.mysql.com/doc/refman/en/using-systemd.html
  Process: 10053 ExecStartPre=/usr/share/mysql-8.0/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
 Main PID: 10096 (mysqld)
   Status: "Server is operational"
    Tasks: 38 (limit: 4915)
   CGroup: /system.slice/mysql.service
           └─10096 /usr/sbin/mysqld

Aug 06 15:54:42 qwfys systemd[1]: Starting MySQL Community Server...
Aug 06 15:54:42 qwfys systemd[1]: Started MySQL Community Server.
lwk@qwfys:~$ 

  我们看到,MySQL8.0 服务已经启动,运行状态良好。

在安装过程中,会依次出现输入密码、确认密码、账户安装模式选择三个对话框,如下所示。

How to install MySQL 8.0 to Linux mint 18.3_第2张图片
初始密码
How to install MySQL 8.0 to Linux mint 18.3_第3张图片
确认密码
How to install MySQL 8.0 to Linux mint 18.3_第4张图片
账户安全模式

Connect to the Server

  MSQL客户端很多,为了方便起见,这里我们使用命令行客户端工具,示例如下:

lwk@qwfys:~$ sudo mysql -uroot -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 10
Server version: 8.0.17 MySQL Community Server - GPL

Copyright (c) 2000, 2019, 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>  \h

For information about MySQL products and services, visit:
   http://www.mysql.com/
For developer information, including the MySQL Reference Manual, visit:
   http://dev.mysql.com/
To buy MySQL Enterprise support, training, or other products, visit:
   https://shop.mysql.com/

List of all MySQL commands:
Note that all text commands must be first on line and end with ';'
?         (\?) Synonym for `help'.
clear     (\c) Clear the current input statement.
connect   (\r) Reconnect to the server. Optional arguments are db and host.
delimiter (\d) Set statement delimiter.
edit      (\e) Edit command with $EDITOR.
ego       (\G) Send command to mysql server, display result vertically.
exit      (\q) Exit mysql. Same as quit.
go        (\g) Send command to mysql server.
help      (\h) Display this help.
nopager   (\n) Disable pager, print to stdout.
notee     (\t) Don't write into outfile.
pager     (\P) Set PAGER [to_pager]. Print the query results via PAGER.
print     (\p) Print current command.
prompt    (\R) Change your mysql prompt.
quit      (\q) Quit mysql.
rehash    (\#) Rebuild completion hash.
source    (\.) Execute an SQL script file. Takes a file name as an argument.
status    (\s) Get status information from the server.
system    (\!) Execute a system shell command.
tee       (\T) Set outfile [to_outfile]. Append everything into given outfile.
use       (\u) Use another database. Takes database name as argument.
charset   (\C) Switch to another charset. Might be needed for processing binlog with multi-byte charsets.
warnings  (\W) Show warnings after every statement.
nowarning (\w) Don't show warnings after every statement.
resetconnection(\x) Clean session context.

For server side help, type 'help contents'

mysql> 

Create database

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
4 rows in set (0.00 sec)

mysql> create database lwk;
Query OK, 1 row affected (0.01 sec)

mysql> use lwk;
Database changed
mysql> 

Grant user for Database

mysql> CREATE USER 'lwk'@'%' IDENTIFIED WITH mysql_native_password BY '4F763CCD7253D8C1794D';
Query OK, 0 rows affected (0.01 sec)

mysql> GRANT ALL PRIVILEGES ON *.* TO 'lwk'@'%';
Query OK, 0 rows affected (0.01 sec)
mysql> exit
Bye
lwk@qwfys:~$
lwk@qwfys:~$ mysql -ulwk -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 11
Server version: 8.0.17 MySQL Community Server - GPL

Copyright (c) 2000, 2019, 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> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| lwk                |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
5 rows in set (0.00 sec)

mysql> 

#Uninstall

lwk@qwfys ~ $ apt purge mysql-client mysql-server  -y
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
  libaec0 libaio1 libarmadillo6 libarpack2 libctemplate2v5 libdap17v5 libdapclient6v5 libepsilon1 libfreexl1 libgdal1i libgeos-3.5.0 libgeos-c1v5 libhdf4-0-alt libhdf5-10 libkmlbase1 libkmldom1 libkmlengine1 libmecab2 libminizip1
  libmysqlclient20 libmysqlcppconn7v5 libnetcdf11 libodbc1 libogdi3.2 libopenjp2-7 libpcrecpp0v5 libproj9 libspatialite7 libsuperlu4 libsz2 liburiparser1 libvsqlitepp3v5 libxerces-c3.1 mysql-common mysql-community-client
  mysql-community-client-core mysql-community-server-core mysql-workbench-data odbcinst odbcinst1debian2 proj-data python-mysql.connector python-pyodbc
Use 'sudo apt autoremove' to remove them.
The following packages will be REMOVED:
  mysql-client* mysql-community-server* mysql-server* mysql-workbench*
0 upgraded, 0 newly installed, 4 to remove and 0 not upgraded.
After this operation, 227 MB disk space will be freed.
(Reading database ... 303464 files and directories currently installed.)
Removing mysql-server (8.0.11-1ubuntu16.04) ...
Removing mysql-community-server (8.0.11-1ubuntu16.04) ...
update-alternatives: using /etc/mysql/my.cnf.fallback to provide /etc/mysql/my.cnf (my.cnf) in auto mode
Purging configuration files for mysql-community-server (8.0.11-1ubuntu16.04) ...
.
Removing mysql-client (8.0.11-1ubuntu16.04) ...
Removing mysql-workbench (6.3.6+dfsg-0ubuntu1) ...
Purging configuration files for mysql-workbench (6.3.6+dfsg-0ubuntu1) ...
Processing triggers for shared-mime-info (1.5-2ubuntu0.1) ...
Processing triggers for gnome-menus (3.13.3-6ubuntu3.1) ...
Processing triggers for desktop-file-utils (0.22+linuxmint1) ...
Processing triggers for mime-support (3.59ubuntu1) ...
lwk@qwfys ~ $ apt autoremove 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages will be REMOVED:
  libaec0 libaio1 libarmadillo6 libarpack2 libctemplate2v5 libdap17v5 libdapclient6v5 libepsilon1 libfreexl1 libgdal1i libgeos-3.5.0 libgeos-c1v5 libhdf4-0-alt libhdf5-10 libkmlbase1 libkmldom1 libkmlengine1 libmecab2 libminizip1
  libmysqlclient20 libmysqlcppconn7v5 libnetcdf11 libodbc1 libogdi3.2 libopenjp2-7 libpcrecpp0v5 libproj9 libspatialite7 libsuperlu4 libsz2 liburiparser1 libvsqlitepp3v5 libxerces-c3.1 mysql-common mysql-community-client
  mysql-community-client-core mysql-community-server-core mysql-workbench-data odbcinst odbcinst1debian2 proj-data python-mysql.connector python-pyodbc
0 upgraded, 0 newly installed, 43 to remove and 0 not upgraded.
After this operation, 279 MB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 303230 files and directories currently installed.)
Removing libgdal1i (1.11.3+dfsg-3build2) ...
Removing libnetcdf11 (1:4.4.0-2) ...
Removing libhdf5-10:amd64 (1.8.16+docs-4ubuntu1) ...
Removing libsz2:amd64 (0.3.2-1) ...
Removing libaec0:amd64 (0.3.2-1) ...
Removing mysql-community-server-core (8.0.11-1ubuntu16.04) ...
Removing libaio1:amd64 (0.3.110-2) ...
Removing libarmadillo6 (1:6.500.5+dfsg-1) ...
Removing libarpack2 (3.3.0-1build2) ...
Removing libctemplate2v5 (2.2-5ubuntu1) ...
Removing libdapclient6v5:amd64 (3.15.1-7) ...
Removing libdap17v5:amd64 (3.15.1-7) ...
Removing libepsilon1:amd64 (0.9.2-3ubuntu1) ...
Removing libspatialite7:amd64 (4.3.0a-5) ...
Removing libfreexl1:amd64 (1.0.2-1) ...
Removing libgeos-c1v5 (3.5.0-1ubuntu2) ...
Removing libgeos-3.5.0 (3.5.0-1ubuntu2) ...
Removing libhdf4-0-alt (4.2.10-3.2) ...
Removing libkmlengine1:amd64 (1.3.0-1) ...
Removing libkmldom1:amd64 (1.3.0-1) ...
Removing libkmlbase1:amd64 (1.3.0-1) ...
Removing libmecab2 (0.996-1.2ubuntu1) ...
Removing libminizip1:amd64 (1.1-8) ...
Removing libmysqlcppconn7v5 (1.1.7-0ubuntu1) ...
Removing libmysqlclient20:amd64 (5.7.22-0ubuntu0.16.04.1) ...
Removing python-pyodbc (3.0.7-0ubuntu2) ...
Removing libodbc1:amd64 (2.3.1-4.1) ...
Removing libogdi3.2 (3.2.0~beta2-7.1build1) ...
Removing libopenjp2-7:amd64 (2.1.0-2.1ubuntu0.1) ...
Removing libpcrecpp0v5:amd64 (2:8.38-3.1) ...
Removing libproj9 (4.9.2-2) ...
Removing libsuperlu4:amd64 (4.3+dfsg-3) ...
Removing liburiparser1:amd64 (0.8.4-1) ...
Removing libvsqlitepp3v5:amd64 (0.3.13-3.1) ...
Removing libxerces-c3.1:amd64 (3.1.3+debian-1) ...
Removing mysql-community-client (8.0.11-1ubuntu16.04) ...
Removing mysql-common (8.0.11-1ubuntu16.04) ...
Removing mysql-community-client-core (8.0.11-1ubuntu16.04) ...
Removing mysql-workbench-data (6.3.6+dfsg-0ubuntu1) ...
Removing proj-data (4.9.2-2) ...
Removing python-mysql.connector (2.0.4-1) ...
Removing odbcinst (2.3.1-4.1) ...
Removing odbcinst1debian2:amd64 (2.3.1-4.1) ...
Processing triggers for libc-bin (2.23-0ubuntu10) ...
Processing triggers for man-db (2.7.5-1) ...
Processing triggers for hicolor-icon-theme (0.15-0ubuntu1) ...
lwk@qwfys ~ $

How to install MySQL 8.0 to Linux mint 18.3_第5张图片

install mysql webbench

lwk@qwfys:~$ apt install mysql-workbench-community
[sudo] password for lwk:       
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  libpcrecpp0v5
Suggested packages:
  libproj-dev
The following NEW packages will be installed:
  libpcrecpp0v5 mysql-workbench-community
0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
Need to get 20.8 MB of archives.
After this operation, 118 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://repo.mysql.com/apt/ubuntu bionic/mysql-tools amd64 mysql-workbench-community amd64 8.0.17-1ubuntu18.04 [20.8 MB]
Get:2 http://mirrors.ustc.edu.cn/ubuntu bionic/main amd64 libpcrecpp0v5 amd64 2:8.39-9 [15.3 kB]
Fetched 20.8 MB in 17s (1,212 kB/s)                                                                                                                                                                                                          
Selecting previously unselected package libpcrecpp0v5:amd64.
(Reading database ... 325011 files and directories currently installed.)
Preparing to unpack .../libpcrecpp0v5_2%3a8.39-9_amd64.deb ...
Unpacking libpcrecpp0v5:amd64 (2:8.39-9) ...
Selecting previously unselected package mysql-workbench-community.
Preparing to unpack .../mysql-workbench-community_8.0.17-1ubuntu18.04_amd64.deb ...
Unpacking mysql-workbench-community (8.0.17-1ubuntu18.04) ...
Processing triggers for mime-support (3.60ubuntu1) ...
Processing triggers for desktop-file-utils (0.23+linuxmint6) ...
Processing triggers for libc-bin (2.27-3ubuntu1) ...
Processing triggers for shared-mime-info (1.9-2) ...
Setting up libpcrecpp0v5:amd64 (2:8.39-9) ...
Processing triggers for gnome-menus (3.13.3-11ubuntu1.1) ...
Processing triggers for hicolor-icon-theme (0.17-2) ...
Setting up mysql-workbench-community (8.0.17-1ubuntu18.04) ...
Processing triggers for libc-bin (2.27-3ubuntu1) ...
lwk@qwfys:~$ 

How to install MySQL 8.0 to Linux mint 18.3_第6张图片
How to install MySQL 8.0 to Linux mint 18.3_第7张图片
https://dev.mysql.com/doc/refman/8.0/en/adding-users.html

你可能感兴趣的:(Linux)