1、下载安装包
下载网址
选择DEB Bundle,点击右侧Download。
2、安装
将安装包上传到服务器,解压
安装顺序
dpkg -i mysql-common_5.7.22-1ubuntu16.04_amd64.deb
dpkg-preconfigure mysql-community-server_5.7.22-1ubuntu16.04_amd64.deb
dpkg -i libmysqlclient20_5.7.22-1ubuntu16.04_amd64.deb
dpkg -i libmysqlclient-dev_5.7.22-1ubuntu16.04_amd64.deb
dpkg -i libmysqld-dev_5.7.22-1ubuntu16.04_amd64.deb
dpkg -i libaio1_0.3.110-5_amd64.deb
dpkg -i mysql-community-client_5.7.22-1ubuntu16.04_amd64.deb
dpkg -i mysql-client_5.7.22-1ubuntu16.04_amd64.deb
dpkg -i mysql-common_5.7.22-1ubuntu16.04_amd64.deb
dpkg -i libmecab2_0.996-5_amd64.deb
dpkg -i mysql-community-server_5.7.22-1ubuntu16.04_amd64.deb
其中libaio1_0.3.110-5_amd64.deb 和 libmecab2_0.996-5_amd64.deb是安装所需要的依赖包
在安装mysql-community-server_5.7.22-1ubuntu16.04_amd64.deb,会显示图形化界面,输入两次密码即可
以下是详细的安装过程
root@Kylin:/opt# mkdir mysql
root@Kylin:/opt#
root@Kylin:/opt#
root@Kylin:/opt# tar -xf mysql-server_5.7.22-1ubuntu16.04_amd64.deb-bundle.tar -C mysql/
root@Kylin:/opt#
root@Kylin:/opt#
root@Kylin:/opt# ll
总用量 122584
drwxr-xr-x 3 root root 4096 4月 9 19:22 ./
drwxrwxr-x 23 root root 4096 4月 10 2021 ../
-rw-r--r-- 1 root root 12340 4月 9 19:21 libaio1_0.3.112-9_arm64.deb
drwxr-xr-x 2 root root 4096 4月 9 19:23 mysql/
-rw-r--r-- 1 root root 125491200 4月 9 19:21 mysql-server_5.7.22-1ubuntu16.04_amd64.deb-bundle.tar
root@Kylin:/opt#
root@Kylin:/opt# cd mysql/
root@Kylin:/opt/mysql# ll
总用量 122580
drwxr-xr-x 2 root root 4096 4月 9 19:23 ./
drwxr-xr-x 3 root root 4096 4月 9 19:22 ../
-rw-r--r-- 1 7155 31415 839962 3月 4 2018 libmysqlclient20_5.7.22-1ubuntu16.04_amd64.deb
-rw-r--r-- 1 7155 31415 1192920 3月 4 2018 libmysqlclient-dev_5.7.22-1ubuntu16.04_amd64.deb
-rw-r--r-- 1 7155 31415 17546554 3月 4 2018 libmysqld-dev_5.7.22-1ubuntu16.04_amd64.deb
-rw-r--r-- 1 7155 31415 12322 3月 4 2018 mysql-client_5.7.22-1ubuntu16.04_amd64.deb
-rw-r--r-- 1 7155 31415 15180 3月 4 2018 mysql-common_5.7.22-1ubuntu16.04_amd64.deb
-rw-r--r-- 1 7155 31415 7856138 3月 4 2018 mysql-community-client_5.7.22-1ubuntu16.04_amd64.deb
-rw-r--r-- 1 7155 31415 25396182 3月 4 2018 mysql-community-server_5.7.22-1ubuntu16.04_amd64.deb
-rw-r--r-- 1 7155 31415 48738976 3月 4 2018 mysql-community-source_5.7.22-1ubuntu16.04_amd64.deb
-rw-r--r-- 1 7155 31415 23857528 3月 4 2018 mysql-community-test_5.7.22-1ubuntu16.04_amd64.deb
-rw-r--r-- 1 7155 31415 12318 3月 4 2018 mysql-server_5.7.22-1ubuntu16.04_amd64.deb
-rw-r--r-- 1 7155 31415 12328 3月 4 2018 mysql-testsuite_5.7.22-1ubuntu16.04_amd64.deb
root@Kylin:/opt/mysql#
root@Kylin:/opt/mysql# dpkg -i mysql-common_5.7.22-1ubuntu16.04_amd64.deb
正在选中未选择的软件包 mysql-common。
(正在读取数据库 ... 系统当前共安装有 64415 个文件和目录。)
正准备解包 mysql-common_5.7.22-1ubuntu16.04_amd64.deb ...
正在解包 mysql-common (5.7.22-1ubuntu16.04) ...
正在设置 mysql-common (5.7.22-1ubuntu16.04) ...
update-alternatives: 使用 /etc/mysql/my.cnf.fallback 来在自动模式中提供 /etc/mysql/my.cnf (my.cnf)
root@Kylin:/opt/mysql#
root@Kylin:/opt/mysql# dpkg-preconfigure mysql-community-server_5.7.22-1ubuntu16.04_amd64.deb
root@Kylin:/opt/mysql#
root@Kylin:/opt/mysql# dpkg -i libmysqlclient20_5.7.22-1ubuntu16.04_amd64.deb
正在选中未选择的软件包 libmysqlclient20:amd64。
(正在读取数据库 ... 系统当前共安装有 64430 个文件和目录。)
正准备解包 libmysqlclient20_5.7.22-1ubuntu16.04_amd64.deb ...
正在解包 libmysqlclient20:amd64 (5.7.22-1ubuntu16.04) ...
正在设置 libmysqlclient20:amd64 (5.7.22-1ubuntu16.04) ...
正在处理用于 libc-bin (2.23-0kord11k20.5) 的触发器 ...
root@Kylin:/opt/mysql# dpkg -i libmysqlclient-dev_5.7.22-1ubuntu16.04_amd64.deb
正在选中未选择的软件包 libmysqlclient-dev。
(正在读取数据库 ... 系统当前共安装有 64438 个文件和目录。)
正准备解包 libmysqlclient-dev_5.7.22-1ubuntu16.04_amd64.deb ...
正在解包 libmysqlclient-dev (5.7.22-1ubuntu16.04) ...
正在设置 libmysqlclient-dev (5.7.22-1ubuntu16.04) ...
正在处理用于 man-db (2.7.5-1kord) 的触发器 ...
root@Kylin:/opt/mysql# dpkg -i libmysqld-dev_5.7.22-1ubuntu16.04_amd64.deb
正在选中未选择的软件包 libmysqld-dev。
(正在读取数据库 ... 系统当前共安装有 64559 个文件和目录。)
正准备解包 libmysqld-dev_5.7.22-1ubuntu16.04_amd64.deb ...
正在解包 libmysqld-dev (5.7.22-1ubuntu16.04) ...
正在设置 libmysqld-dev (5.7.22-1ubuntu16.04) ...
root@Kylin:/opt/mysql#
root@Kylin:/opt/mysql# dpkg -i mysql-community-client_5.7.22-1ubuntu16.04_amd64.deb
正在选中未选择的软件包 mysql-community-client。
(正在读取数据库 ... 系统当前共安装有 64567 个文件和目录。)
正准备解包 mysql-community-client_5.7.22-1ubuntu16.04_amd64.deb ...
正在解包 mysql-community-client (5.7.22-1ubuntu16.04) ...
dpkg: 依赖关系问题使得 mysql-community-client 的配置工作不能继续:
mysql-community-client 依赖于 libaio1 (>= 0.3.93);然而:
未安装软件包 libaio1。
dpkg: 处理软件包 mysql-community-client (--install)时出错:
依赖关系问题 - 仍未被配置
正在处理用于 man-db (2.7.5-1kord) 的触发器 ...
在处理时有错误发生:
mysql-community-client
root@Kylin:/opt/mysql#
在执行dpkg -i mysql-community-client_5.7.22-1ubuntu16.04_amd64.deb出现了报错
缺少依赖包libaio1,下载https://pkgs.org/download/libaio1
选择Ubuntu18.04,因为16.04没有了,点击进去
将下载下来的dpkg -i libaio1_0.3.110-5_amd64.deb安装
root@Kylin:~# dpkg -i libaio1_0.3.110-5_amd64.deb
正在选中未选择的软件包 libaio1:amd64。
(正在读取数据库 ... 系统当前共安装有 64624 个文件和目录。)
正准备解包 libaio1_0.3.110-5_amd64.deb ...
正在解包 libaio1:amd64 (0.3.110-5) ...
正在设置 libaio1:amd64 (0.3.110-5) ...
正在处理用于 libc-bin (2.23-0kord11k20.5) 的触发器 ...
root@Kylin:~#
root@Kylin:~#
再次安装mysql-community-client_5.7.22-1ubuntu16.04_amd64.deb
root@Kylin:/opt/mysql# dpkg -i mysql-community-client_5.7.22-1ubuntu16.04_amd64.deb
(正在读取数据库 ... 系统当前共安装有 64631 个文件和目录。)
正准备解包 mysql-community-client_5.7.22-1ubuntu16.04_amd64.deb ...
正在将 mysql-community-client (5.7.22-1ubuntu16.04) 解包到 (5.7.22-1ubuntu16.04) 上 ...
正在设置 mysql-community-client (5.7.22-1ubuntu16.04) ...
正在处理用于 man-db (2.7.5-1kord) 的触发器 ...
root@Kylin:/opt/mysql#
root@Kylin:/opt/mysql# dpkg -i mysql-client_5.7.22-1ubuntu16.04_amd64.deb
正在选中未选择的软件包 mysql-client。
(正在读取数据库 ... 系统当前共安装有 64631 个文件和目录。)
正准备解包 mysql-client_5.7.22-1ubuntu16.04_amd64.deb ...
正在解包 mysql-client (5.7.22-1ubuntu16.04) ...
正在设置 mysql-client (5.7.22-1ubuntu16.04) ...
root@Kylin:/opt/mysql# dpkg -i mysql-common_5.7.22-1ubuntu16.04_amd64.deb
(正在读取数据库 ... 系统当前共安装有 64637 个文件和目录。)
正准备解包 mysql-common_5.7.22-1ubuntu16.04_amd64.deb ...
正在将 mysql-common (5.7.22-1ubuntu16.04) 解包到 (5.7.22-1ubuntu16.04) 上 ...
正在设置 mysql-common (5.7.22-1ubuntu16.04) ...
#####################################################
这里还需要下载一个依赖包libmecab2_0.996-5_amd64.deb
root@Kylin:/opt# dpkg -i libmecab2_0.996-5_amd64.deb
正在选中未选择的软件包 libmecab2:amd64。
(正在读取数据库 ... 系统当前共安装有 64637 个文件和目录。)
正准备解包 libmecab2_0.996-5_amd64.deb ...
正在解包 libmecab2:amd64 (0.996-5) ...
正在设置 libmecab2:amd64 (0.996-5) ...
正在处理用于 libc-bin (2.23-0kord11k20.5) 的触发器 ...
root@Kylin:/opt/mysql# dpkg -i mysql-community-server_5.7.22-1ubuntu16.04_amd64.deb
正在选中未选择的软件包 mysql-community-server。
(正在读取数据库 ... 系统当前共安装有 64118 个文件和目录。)
正准备解包 mysql-community-server_5.7.22-1ubuntu16.04_amd64.deb ...
正在解包 mysql-community-server (5.7.22-1ubuntu16.04) ...
正在设置 mysql-community-server (5.7.22-1ubuntu16.04) ...
update-alternatives: 使用 /etc/mysql/mysql.cnf 来在自动模式中提供 /etc/mysql/my.cnf (my.cnf)
正在处理用于 systemd (229-4kord21.21k5) 的触发器 ...
正在处理用于 ureadahead (0.100.0-19kord) 的触发器 ...
正在处理用于 man-db (2.7.5-1kord) 的触发器 ...
root@Kylin:/opt/mysql#
3、登录mysql
root@Kylin:/opt/mysql# netstat -anp | grep mysql
tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN 9023/mysqld
unix 2 [ ACC ] 流 LISTENING 30971 9023/mysqld /var/run/mysqld/mysqld.sock
root@Kylin:/opt/mysql#
root@Kylin:/opt/mysql# mysql -uroot -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
root@Kylin:/opt/mysql#
root@Kylin:/opt/mysql#
root@Kylin:/opt/mysql# mysql -h 127.0.0.1 -P 3306 -uroot -p123456
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.22 MySQL Community Server (GPL)
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>
mysql>
mysql>
root@Kylin:/opt/mysql# mysql -uroot -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
需要打开远程访问权限
root@Kylin:/opt/mysql# mysql -h 127.0.0.1 -P 3306 -uroot -p123456
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.22 MySQL Community Server (GPL)
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>
mysql>
mysql> grant all privileges on *.* to 'root'@'%' identified by '123456';
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> exit
修改配置文件
vim /etc/mysql/mysql.conf.d/mysqld.cnf
#bind 127.0.0.1 (加#号 注释掉这一行)
重启mysql
service mysql restart
root@Kylin:/opt/mysql# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.7.22 MySQL Community Server (GPL)
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>
登录成功