目录
1 安装
1.1 更新包管理工具apt-get
1.2 安装MySQL服务器端
1.3 安装MySQL客户端
1.4 初始化配置
1.5 检查MySQL服务状态
2 卸载
2.1 查看MySQL依赖项
2.2 卸载mysql-common
2.3 再卸载 mysql-server-8.0
2.4 再用dpkg --list|grep mysql查看,还剩什么就卸载什么
2.5 清除残留数据
1 安装
1.1 更新包管理工具apt-get
sudo apt-get update

1.2 安装MySQL服务器端
sudo apt-get install mysql-server

1.3 安装MySQL客户端
sudo apt-get install mysql-client

1.4 初始化配置
sudo mysql_secure_installation
若初始化密码报错:
Re-enter new password:
... Failed! Error: SET PASSWORD has no significance for user 'root'@'localhost' as the authentication method used doesn't store authentication data in the MySQL server. Please consider using ALTER USER instead if you want to change authentication parameters.
解决方法:
手动配置密码:
root@LNMP:~# mysql
mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password by 'mynewpassword';
Query OK, 0 rows affected (0.02 sec)
再重新初始化:

1.5 检查MySQL服务状态
systemctl status mysql.service

安装完毕。
2 卸载
2.1 查看MySQL依赖项
dpkg --list | grep mysql

2.2 卸载mysql-common
sudo apt-get remove mysql-common

2.3 再卸载 mysql-server-8.0
sudo apt-get autoremove --purge mysql-server-8.0

2.4 再用dpkg --list|grep mysql查看,还剩什么就卸载什么
![]()
2.5 清除残留数据
dpkg -l |grep ^rc|awk '{print $2}' |sudo xargs dpkg -P

卸载完毕。
![]()


















