在 Ubuntu 中安裝 MySQL5.7.20(任意版本)
阿新 • • 發佈:2018-11-09
相關連結:
在 CentOS 1804 中 使用 yum 安裝 MySQL 5.7 最新版
在 CentOS 1804 中 安裝 MySQL 5.7.20 (或任意MySQL版本)
在不開啟 MySQL 3306 埠的情況下,使用 Navicat 進項遠端連線(使用22埠)
在 Ubuntu 中安裝 MySQL5.7.20(任意版本)
CentOS 6/7 安裝 MySQL 8.0.11 (或任意版)
本示例使用的安裝技術來源於官方文件:
https://dev.mysql.com/doc/mysql-apt-repo-quick-guide/en/
安裝準備:
- 安裝MySQL5.7.20(或任意版本)時,需要去MySQL官網下載deb包。
- 網址:http://repo.mysql.com/apt/ubuntu/pool/mysql-5.7/m/mysql-community/
- MySQL需要使用的包為(***代表版本號):
- mysql-common***
- mysql-community-client***
- mysql-client***
- mysql-community-server***
- 其中MySQL5.7.20需要的包如下:
- mysql-common_5.7.20-1ubuntu17.10_amd64.deb
- mysql-community-client_5.7.20-1ubuntu17.10_amd64.deb
- mysql-client_5.7.20-1ubuntu17.10_amd64.deb
- mysql-community-server_5.7.20-1ubuntu17.10_amd64.deb
- 特出情況:
- 在安裝過程可能會遇見缺少包的情況(本示例使用的是Ubuntu 18.04.01,缺少兩個包,分別是libaio1、libmecab2),在安裝過程會講解怎樣去下載和安裝缺少的包。
- 本示例中需要的4個包,在其他版本中不能保證也是僅僅需要這四個包,最簡單粗暴的方法是安裝mysql-community-server***,提示缺少哪個包,就去官網(http://repo.mysql.com/apt/ubuntu/pool/mysql-5.7/m/mysql-community/)去下載哪個包,記住一定要是相同版本的。
- 將安裝需要的4個包上傳至Ubuntu,如圖所示:
- 在安裝包所在的資料夾執行:
安裝第一個包(安裝順序不可更改):[email protected]:/usr/java# dpkg -i mysql-common_5.7.20-1ubuntu17.10_amd64.deb Selecting previously unselected package mysql-common. (Reading database ... 102189 files and directories currently installed.) Preparing to unpack mysql-common_5.7.20-1ubuntu17.10_amd64.deb ... Unpacking mysql-common (5.7.20-1ubuntu17.10) ... Setting up mysql-common (5.7.20-1ubuntu17.10) ... update-alternatives: using /etc/mysql/my.cnf.fallback to provide /etc/mysql/my.cnf (my.cnf) in auto mode [email protected]:/usr/java#
- 安裝第二個包:
提示缺少依賴包libaio1:
去阿里雲開源映象站(連結:https://opsx.alibaba.com/mirror)下載在對應的包。[email protected]:/usr/java# dpkg -i mysql-community-client_5.7.20-1ubuntu17.10_amd64.deb Selecting previously unselected package mysql-community-client. (Reading database ... 102204 files and directories currently installed.) Preparing to unpack mysql-community-client_5.7.20-1ubuntu17.10_amd64.deb ... Unpacking mysql-community-client (5.7.20-1ubuntu17.10) ... dpkg: dependency problems prevent configuration of mysql-community-client: mysql-community-client depends on libaio1 (>= 0.3.93); however: Package libaio1 is not installed. dpkg: error processing package mysql-community-client (--install): dependency problems - leaving unconfigured Processing triggers for man-db (2.8.3-2) ... Errors were encountered while processing: mysql-community-client [email protected]:/usr/java#
利用倉庫名、發行版、架構進行篩選,下載(基本資訊篩選後,下哪個都差不多)後上傳至伺服器,並進行安裝。
讓我們在此安裝一下第二個包:[email protected]:/usr/java# dpkg -i libaio1_0.3.109-4_amd64.deb Selecting previously unselected package libaio1:amd64. (Reading database ... 102261 files and directories currently installed.) Preparing to unpack libaio1_0.3.109-4_amd64.deb ... Unpacking libaio1:amd64 (0.3.109-4) ... Setting up libaio1:amd64 (0.3.109-4) ... Processing triggers for libc-bin (2.27-3ubuntu1) ...
此時便沒有錯誤了。[email protected]:/usr/java# dpkg -i mysql-community-client_5.7.20-1ubuntu17.10_amd64.deb (Reading database ... 102268 files and directories currently installed.) Preparing to unpack mysql-community-client_5.7.20-1ubuntu17.10_amd64.deb ... Unpacking mysql-community-client (5.7.20-1ubuntu17.10) over (5.7.20-1ubuntu17.10) ... Setting up mysql-community-client (5.7.20-1ubuntu17.10) ... Processing triggers for man-db (2.8.3-2) ... [email protected]:/usr/java#
- 安裝第三個包:
[email protected]:/usr/java# dpkg -i mysql-client_5.7.20-1ubuntu17.10_amd64.deb Selecting previously unselected package mysql-client. (Reading database ... 102268 files and directories currently installed.) Preparing to unpack mysql-client_5.7.20-1ubuntu17.10_amd64.deb ... Unpacking mysql-client (5.7.20-1ubuntu17.10) ... Setting up mysql-client (5.7.20-1ubuntu17.10) ... [email protected]:/usr/java#
- 安裝第四個包:
由於此時會提示缺少libmecab2,為了減少篇幅,先安裝此包:
再安裝第四個包:[email protected]:/usr/java# dpkg -i libmecab2_0.996-1.1_amd64.deb Selecting previously unselected package libmecab2. (Reading database ... 102437 files and directories currently installed.) Preparing to unpack libmecab2_0.996-1.1_amd64.deb ... Unpacking libmecab2 (0.996-1.1) ... Setting up libmecab2 (0.996-1.1) ... Processing triggers for libc-bin (2.27-3ubuntu1) ... [email protected]:/usr/java#
安裝過程提示設定密碼(輸入兩次一樣的,為了確認):[email protected]:/usr/java# dpkg -i mysql-community-server_5.7.20-1ubuntu17.10_amd64.deb (Reading database ... 102445 files and directories currently installed.) Preparing to unpack mysql-community-server_5.7.20-1ubuntu17.10_amd64.deb ... . Unpacking mysql-community-server (5.7.20-1ubuntu17.10) over (5.7.20-1ubuntu17.10) ... Setting up mysql-community-server (5.7.20-1ubuntu17.10) ... 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. Processing triggers for ureadahead (0.100.0-20) ... Processing triggers for systemd (237-3ubuntu10.3) ... Processing triggers for man-db (2.8.3-2) ... [email protected]:/usr/java#
- 至此已安裝完成,本人原創,如需轉載,請註明轉載地址。
- 什麼?你們不相信安裝成功了?那我們來試試:
[email protected]:/usr/java# mysql -u root -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 3 Server version: 5.7.20 MySQL Community Server (GPL) Copyright (c) 2000, 2017, 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>
上面登入MySQL時的資訊已經說明了(在此吐槽一下,網上有很對人問,有很多人說查詢MySQL安裝版本,你們記住了嗎?登入MySQL時不是已經給你提示了什麼版本了嗎?)。
相關連結:
在 CentOS 1804 中 使用 yum 安裝 MySQL 5.7 最新版
在 CentOS 1804 中 安裝 MySQL 5.7.20 (或任意MySQL版本)
在不開啟 MySQL 3306 埠的情況下,使用 Navicat 進項遠端連線(使用22埠)
在 Ubuntu 中安裝 MySQL5.7.20(任意版本)
CentOS 6/7 安裝 MySQL 8.0.11 (或任意版)