Ubuntu Server 18.04 安装mysql-comm
1 mysql-community-server-5.7.37 下载
https://dev.mysql.com/downloads/mysql/5.7.html
在官网中的 archives 页面中, 只找到了 5.7.36 , 但是直接搜索5.7.37 却能搜索到, 不知道为什么

2上传到 Ubuntu Server
scp mysql-server_5.7.37-1ubuntu18.04_amd64.deb-bundle.tar wang@192.168.8.131:/home/wang

3 解压
tar -xvf mysql-server_5.7.37-1ubuntu18.04_amd64.deb-bundle.tar
将解压出来的deb包放在某个单独的目录下
4 安装
sudo apt install ./*
apt 也可以安装deb包的, 详细这里
5 首次登陆mysql
安装的时候, 终端会有弹窗让你设置密码, 使用设置的密码登录
sudo mysql
OR sudo mysql -u root -p
由于我没有设置密码, 所以不输入, 或者任意输入都是可以登录的
不使用 sudo 是无法登录的, 即使使用 -u root
5.1 查看 mysql.user 表结构
desc mysql.user
发现, 当前版本的mysql 中password字段被替换成了authentication_string

5.2
select user, host, authentication_string from mysql.user;

5.3 注意提示, mysql.session 和 mysql.sys 密码也是无效的, 要给所有的root用户设置一个密码
update mysql.user set authentication_string = password('YOURPASSWORD') where user='root';
需要重启mysql
5.4 注意到我们设置了密码后, 使用root还是可以空密码以及任意密码登录.
认为是 plugin = auth_socket的问题

5.5 修改 plugin = mysql_native_password
update mysql.user set plugin='mysql_native_password' where user='root';

5.6 重启mysql后再次尝试登录发现 'mysql_nvtive_password' is not loaded
sudo mysql -u root -p
sudo mysql
都无法登录
5.7 跳过密码验证登录
定位文件 /etc/mysql/mysql.conf.d/mysql.cnf
添加 skip-grant-tables
重启mysql生效

5.8 plugin改回auth_socket
update mysql.user set plugin = 'auth_socket' where user='root';
5.9 搜索相关资料了解到了为什么 plugin=auth_socker的时候root用户任意密码可以登录, 以及, auth_socket
相比mysql_native_password
更安全点
链接
最终解决
6.1 首先修改 plugin = 'mysql_native_password'
6.2 然后文件: /etc/mysql/myql.conf.d/mysql.cnf
中添加 skip-grant-tables
***这个时候登录mysql的时候就不会出现 ***plugin 'mysql_native_password' is not loaded
6.3 最后修改root登录的密码 update mysql.user set authentication_string = password('YOURPASSWORD') where user='root';
和关闭skip-grant-tables
重启mysql, 问题解决.