# 安装mysql服务
sudo apt-get install mysql-server
# 安装mysql客户端
sudo apt-get install mysql-client
# 修改配置文件
sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf
# 添加跳过密码登录的命令
skip-grant-tables
# 开启远程登录
bind-address = 127.0.0.1
# 重启服务
sudo mysql service mysql start
# 登录数据库
mysql -uroot -p
# 执行SQL语句
use mysql;
select user, plugin from user;
update user set authentication_string=password('密码'), plugin='mysql_native_password' where user='root';
flush privileges;
# 返回配置文件注销跳过登录命令
# 重启服务
sudo mysql service mysql start
# 接下来是开启远程连接mysql(个人需求)
# 更新权限
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '密码' WITH GRANT OPTION;
# 刷新表
flush privileges;
# 重启服务
sudo mysql service mysql start
# 完成后可尝试在本地用工具连接
最后附上大佬的视频