安装
root@ubuntu:~$ sudo apt-get update
命中:1 http://security.ubuntu.com/ubuntu bionic-security InRelease
命中:2 http://cn.archive.ubuntu.com/ubuntu bionic InRelease
命中:3 http://cn.archive.ubuntu.com/ubuntu bionic-updates InRelease
命中:4 https://packages.grafana.com/oss/deb stable InRelease
命中:5 http://cn.archive.ubuntu.com/ubuntu bionic-backports InRelease
正在读取软件包列表... 完成
root@ubuntu:~$ sudo apt-get install mysql-server
正在读取软件包列表... 完成
正在分析软件包的依赖关系树
正在读取状态信息... 完成
将会同时安装下列软件:
libaio1 libevent-core-2.1-6 mysql-client-5.7 mysql-client-core-5.7 mysql-common mysql-server-5.7
mysql-server-core-5.7
建议安装:
mailx tinyca
下列【新】软件包将被安装:
libaio1 libevent-core-2.1-6 mysql-client-5.7 mysql-client-core-5.7 mysql-common mysql-server
mysql-server-5.7 mysql-server-core-5.7
升级了 0 个软件包,新安装了 8 个软件包,要卸载 0 个软件包,有 10 个软件包未被升级。
需要下载 19.4 MB 的归档。
解压缩后会消耗 155 MB 的额外空间。
您希望继续执行吗? [Y/n] y
获取:1 http://cn.archive.ubuntu.com/ubuntu bionic/main amd64 mysql-common all 5.8+1.0.4 [7,308 B]
获取:2 http://cn.archive.ubuntu.com/ubuntu bionic-updates/main amd64 libaio1 amd64 0.3.110-5ubuntu0.1 [6,476 B]
获取:3 http://cn.archive.ubuntu.com/ubuntu bionic-updates/main amd64 mysql-client-core-5.7 amd64 5.7.39-0ubuntu0.18.04.2 [6,746 kB]
获取:4 http://cn.archive.ubuntu.com/ubuntu bionic-updates/main amd64 mysql-client-5.7 amd64 5.7.39-0ubuntu0.18.04.2 [2,026 kB]
获取:5 http://cn.archive.ubuntu.com/ubuntu bionic-updates/main amd64 mysql-server-core-5.7 amd64 5.7.39-0ubuntu0.18.04.2 [7,531 kB]
获取:6 http://cn.archive.ubuntu.com/ubuntu bionic/main amd64 libevent-core-2.1-6 amd64 2.1.8-stable-4build1 [85.9 kB]
获取:7 http://cn.archive.ubuntu.com/ubuntu bionic-updates/main amd64 mysql-server-5.7 amd64 5.7.39-0ubuntu0.18.04.2 [3,001 kB]
获取:8 http://cn.archive.ubuntu.com/ubuntu bionic-updates/main amd64 mysql-server all 5.7.39-0ubuntu0.18.04.2 [9,944 B]
已下载 19.4 MB,耗时 2分 45秒 (118 kB/s)
正在预设定软件包 ...
正在选中未选择的软件包 mysql-common。
(正在读取数据库 ... 系统当前共安装有 203290 个文件和目录。)
正准备解包 .../0-mysql-common_5.8+1.0.4_all.deb ...
正在解包 mysql-common (5.8+1.0.4) ...
正在选中未选择的软件包 libaio1:amd64。
正准备解包 .../1-libaio1_0.3.110-5ubuntu0.1_amd64.deb ...
正在解包 libaio1:amd64 (0.3.110-5ubuntu0.1) ...
正在选中未选择的软件包 mysql-client-core-5.7。
正准备解包 .../2-mysql-client-core-5.7_5.7.39-0ubuntu0.18.04.2_amd64.deb ...
正在解包 mysql-client-core-5.7 (5.7.39-0ubuntu0.18.04.2) ...
正在选中未选择的软件包 mysql-client-5.7。
正准备解包 .../3-mysql-client-5.7_5.7.39-0ubuntu0.18.04.2_amd64.deb ...
正在解包 mysql-client-5.7 (5.7.39-0ubuntu0.18.04.2) ...
正在选中未选择的软件包 mysql-server-core-5.7。
正准备解包 .../4-mysql-server-core-5.7_5.7.39-0ubuntu0.18.04.2_amd64.deb ...
正在解包 mysql-server-core-5.7 (5.7.39-0ubuntu0.18.04.2) ...
正在选中未选择的软件包 libevent-core-2.1-6:amd64。
正准备解包 .../5-libevent-core-2.1-6_2.1.8-stable-4build1_amd64.deb ...
正在解包 libevent-core-2.1-6:amd64 (2.1.8-stable-4build1) ...
正在设置 mysql-common (5.8+1.0.4) ...
update-alternatives: 使用 /etc/mysql/my.cnf.fallback 来在自动模式中提供 /etc/mysql/my.cnf (my.cnf)
正在选中未选择的软件包 mysql-server-5.7。
(正在读取数据库 ... 系统当前共安装有 203458 个文件和目录。)
正准备解包 .../mysql-server-5.7_5.7.39-0ubuntu0.18.04.2_amd64.deb ...
正在解包 mysql-server-5.7 (5.7.39-0ubuntu0.18.04.2) ...
正在选中未选择的软件包 mysql-server。
正准备解包 .../mysql-server_5.7.39-0ubuntu0.18.04.2_all.deb ...
正在解包 mysql-server (5.7.39-0ubuntu0.18.04.2) ...
正在设置 libevent-core-2.1-6:amd64 (2.1.8-stable-4build1) ...
正在设置 libaio1:amd64 (0.3.110-5ubuntu0.1) ...
正在设置 mysql-client-core-5.7 (5.7.39-0ubuntu0.18.04.2) ...
正在设置 mysql-server-core-5.7 (5.7.39-0ubuntu0.18.04.2) ...
正在设置 mysql-client-5.7 (5.7.39-0ubuntu0.18.04.2) ...
正在设置 mysql-server-5.7 (5.7.39-0ubuntu0.18.04.2) ...
update-alternatives: 使用 /etc/mysql/mysql.cnf 来在自动模式中提供 /etc/mysql/my.cnf (my.cnf)
Renaming removed key_buffer and myisam-recover options (if present)
Created symlink /etc/systemd/system/multi-user.target.wants/mysql.service → /lib/systemd/system/mysql.service.
正在设置 mysql-server (5.7.39-0ubuntu0.18.04.2) ...
正在处理用于 libc-bin (2.27-3ubuntu1.6) 的触发器 ...
正在处理用于 systemd (237-3ubuntu10.56) 的触发器 ...
正在处理用于 man-db (2.8.3-2ubuntu0.1) 的触发器 ...
正在处理用于 ureadahead (0.100.0-21) 的触发器 ...
root@ubuntu:~$ service mysql status
● mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
Active: active (running) since Thu 2022-09-29 14:29:32 CST; 1min 16s ago
Main PID: 50615 (mysqld)
Tasks: 27 (limit: 2283)
CGroup: /system.slice/mysql.service
└─50615 /usr/sbin/mysqld --daemonize --pid-file=/run/mysqld/mysqld.pid
9月 29 14:29:32 u-reids1 systemd[1]: Starting MySQL Community Server...
9月 29 14:29:32 u-reids1 systemd[1]: Started MySQL Community Server.
root@ubuntu:~$ sudo netstat -tap | grep mysql
tcp 0 0 localhost:mysql 0.0.0.0:* LISTEN 50615/mysqld
root@ubuntu:~$ mysql --version
mysql Ver 14.14 Distrib 5.7.39, for Linux (x86_64) using EditLine wrapper
登录
root@ubuntu:~$ sudo cat /etc/mysql/debian.cnf
[client]
host = localhost
user = debian-sys-maint
password = xfyE1847Qv2B4oTA
socket = /var/run/mysqld/mysqld.sock
[mysql_upgrade]
host = localhost
user = debian-sys-maint
password = xfyE1847Qv2B4oTA
socket = /var/run/mysqld/mysqld.sock
root@ubuntu:~$ mysql -u debian-sys-maint -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.39-0ubuntu0.18.04.2 (Ubuntu)
Copyright (c) 2000, 2022, Oracle and/or its affiliates.
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> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> create user 'bhiot'@'%' identified by '123456';
Query OK, 0 rows affected (0.00 sec)
mysql> grant all on *.* to 'bhiot'@'%' identified by '123456';
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> exit
Bye
root@ubuntu:~$ mysql -u bhiot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.7.39-0ubuntu0.18.04.2 (Ubuntu)
Copyright (c) 2000, 2022, Oracle and/or its affiliates.
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>
卸载
root@ubuntu:~$ dpkg --list | grep mysql
ii mysql-client-5.7 5.7.39-0ubuntu0.18.04.2 amd64 MySQL database client binaries
ii mysql-client-core-5.7 5.7.39-0ubuntu0.18.04.2 amd64 MySQL database core client binaries
ii mysql-common 5.8+1.0.4 all MySQL database common files, e.g. /etc/mysql/my.cnf
ii mysql-server 5.7.39-0ubuntu0.18.04.2 all MySQL database server (metapackage depending on the latest version)
ii mysql-server-5.7 5.7.39-0ubuntu0.18.04.2 amd64 MySQL database server binaries and system database setup
ii mysql-server-core-5.7 5.7.39-0ubuntu0.18.04.2 amd64 MySQL database server binaries
root@ubuntu:~$ sudo apt-get autoremove --purge mysql-server
正在读取软件包列表... 完成
正在分析软件包的依赖关系树
正在读取状态信息... 完成
下列软件包将被【卸载】:
libaio1* libevent-core-2.1-6* linux-hwe-5.4-headers-5.4.0-117* linux-hwe-5.4-headers-5.4.0-120*
linux-hwe-5.4-headers-5.4.0-84* mysql-client-5.7* mysql-client-core-5.7* mysql-common* mysql-server*
mysql-server-5.7* mysql-server-core-5.7*
升级了 0 个软件包,新安装了 0 个软件包,要卸载 11 个软件包,有 10 个软件包未被升级。
解压缩后将会空出 369 MB 的空间。
您希望继续执行吗? [Y/n] y
(正在读取数据库 ... 系统当前共安装有 256825 个文件和目录。)
正在卸载 mysql-server (5.7.39-0ubuntu0.18.04.2) ...
正在卸载 mysql-server-5.7 (5.7.39-0ubuntu0.18.04.2) ...
update-alternatives: 使用 /etc/mysql/my.cnf.fallback 来在自动模式中提供 /etc/mysql/my.cnf (my.cnf)
正在卸载 mysql-server-core-5.7 (5.7.39-0ubuntu0.18.04.2) ...
正在卸载 mysql-client-5.7 (5.7.39-0ubuntu0.18.04.2) ...
正在卸载 mysql-client-core-5.7 (5.7.39-0ubuntu0.18.04.2) ...
正在卸载 libaio1:amd64 (0.3.110-5ubuntu0.1) ...
正在卸载 libevent-core-2.1-6:amd64 (2.1.8-stable-4build1) ...
正在卸载 linux-hwe-5.4-headers-5.4.0-117 (5.4.0-117.132~18.04.1) ...
正在卸载 linux-hwe-5.4-headers-5.4.0-120 (5.4.0-120.136~18.04.1) ...
正在卸载 linux-hwe-5.4-headers-5.4.0-84 (5.4.0-84.94~18.04.1) ...
正在卸载 mysql-common (5.8+1.0.4) ...
正在处理用于 man-db (2.8.3-2ubuntu0.1) 的触发器 ...
正在处理用于 libc-bin (2.27-3ubuntu1.6) 的触发器 ...
(正在读取数据库 ... 系统当前共安装有 203309 个文件和目录。)
正在清除 mysql-common (5.8+1.0.4) 的配置文件 ...
正在清除 mysql-server-5.7 (5.7.39-0ubuntu0.18.04.2) 的配置文件 ...
正在处理用于 systemd (237-3ubuntu10.56) 的触发器 ...
正在处理用于 ureadahead (0.100.0-21) 的触发器 ...
sh: 0: getcwd() failed: No such file or directory
root@ubuntu:~$ dpkg -l | grep ^rc | awk '{print $2}' | sudo xargs dpkg -P
(正在读取数据库 ... 系统当前共安装有 203291 个文件和目录。)
正在清除 gir1.2-gudev-1.0:amd64 (1:232-2) 的配置文件 ...
正在清除 linux-image-5.4.0-117-generic (5.4.0-117.132~18.04.1) 的配置文件 ...
正在清除 linux-image-5.4.0-120-generic (5.4.0-120.136~18.04.1) 的配置文件 ...
正在清除 linux-image-5.4.0-84-generic (5.4.0-84.94~18.04.1) 的配置文件 ...
正在清除 linux-modules-5.4.0-117-generic (5.4.0-117.132~18.04.1) 的配置文件 ...
正在清除 linux-modules-5.4.0-120-generic (5.4.0-120.136~18.04.1) 的配置文件 ...
正在清除 linux-modules-5.4.0-84-generic (5.4.0-84.94~18.04.1) 的配置文件 ...
正在清除 linux-modules-extra-5.4.0-117-generic (5.4.0-117.132~18.04.1) 的配置文件 ...
正在清除 linux-modules-extra-5.4.0-120-generic (5.4.0-120.136~18.04.1) 的配置文件 ...
正在清除 linux-modules-extra-5.4.0-84-generic (5.4.0-84.94~18.04.1) 的配置文件 ...
正在清除 usb-creator-common (0.3.5ubuntu18.04.2) 的配置文件 ...
正在处理用于 dbus (1.12.2-1ubuntu1.3) 的触发器 ...
- 更新一下软件源,至此,Mysql5.7就卸载干净了
root@ubuntu:~$ sudo apt-get update
获取:1 http://security.ubuntu.com/ubuntu bionic-security InRelease [88.7 kB]
命中:2 http://cn.archive.ubuntu.com/ubuntu bionic InRelease
命中:3 https://packages.grafana.com/oss/deb stable InRelease
获取:4 http://cn.archive.ubuntu.com/ubuntu bionic-updates InRelease [88.7 kB]
获取:5 http://security.ubuntu.com/ubuntu bionic-security/main amd64 DEP-11 Metadata [55.2 kB]
获取:6 http://cn.archive.ubuntu.com/ubuntu bionic-backports InRelease [83.3 kB]
获取:7 http://security.ubuntu.com/ubuntu bionic-security/universe amd64 DEP-11 Metadata [60.9 kB]
获取:8 http://cn.archive.ubuntu.com/ubuntu bionic-updates/main amd64 DEP-11 Metadata [297 kB]
获取:9 http://security.ubuntu.com/ubuntu bionic-security/multiverse amd64 DEP-11 Metadata [2,464 B]
获取:10 http://cn.archive.ubuntu.com/ubuntu bionic-updates/universe amd64 DEP-11 Metadata [301 kB]
获取:11 http://cn.archive.ubuntu.com/ubuntu bionic-updates/multiverse amd64 DEP-11 Metadata [2,468 B]
获取:12 http://cn.archive.ubuntu.com/ubuntu bionic-backports/main amd64 DEP-11 Metadata [8,116 B]
获取:13 http://cn.archive.ubuntu.com/ubuntu bionic-backports/universe amd64 DEP-11 Metadata [10.0 kB]
已下载 998 kB,耗时 10秒 (104 kB/s)
正在读取软件包列表... 完成