检查删除原有的mysql(可以不做,自己记录)
1、 下载
MySQL :: Download MySQL Community Server (Archived Versions)
wget https://cdn.mysql.com/archives/mysql-8.0/mysql-server_8.0.32-1ubuntu20.04_amd64.deb-bundle.tar
2、解压到指定目录下
tar xvf mysql-server_8.0.32-1ubuntu20.04_amd64.deb-bundle.tar -C /opt/mysql-8.0.32/
3、安装依赖
sudo apt install -y libaio1 libmecab2 man-db libc-bin
4、安装mysql
dpkg -i mysql-community-client-plugins_8.0.32-1ubuntu20.04_amd64.deb
dpkg -i mysql-community-client-core_8.0.32-1ubuntu20.04_amd64.deb
dpkg -i mysql-common_8.0.32-1ubuntu20.04_amd64.deb
dpkg -i mysql-community-client_8.0.32-1ubuntu20.04_amd64.deb
dpkg -i mysql-client_8.0.32-1ubuntu20.04_amd64.deb
dpkg -i mysql-community-server-core_8.0.32-1ubuntu20.04_amd64.deb
dpkg -i mysql-community-server_8.0.32-1ubuntu20.04_amd64.deb
确认完密码后,有个选项,我选的第一个,第二个好像是mysql5啥的。完了后就可以登录了。
5、远程连接
使用远程连接工具报错
ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '你的密码';
systemctl restart mysql # 重启mysql
远程连接正常
6、开机自启动
参考博客:Ubuntu/Linux安装JDK、Mysql、Redis、Rabbitmq、Nginx 并设置开机自启动_ubuntu service mysql start 自动启动-CSDN博客
在centos中开机自启动命令 systemctl enable mysqld
在buntu中是 systemctl enable mysql
systemctl restart mysql # 重启
systemctl status mysql # 查看状态