sudo apt update
sudo apt install mysql-server-8.0 mysql-client-8.0
sudo mysql # 进入mysqlshell后输入下面的命令设置mysql的密码
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';
2013 - Lost connection to MySQL server at 'handshake: reading initial communication packet', system error: 11
修改配置文件配置允许远程连接
sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf?
其中之‘ /etc/mysql/mysql.conf.d/mysqld.cnf ’ 是ubuntu22.04中mysql8.0.35的具体配置文件路径,不同的版本文件路径有些差异,读者可以从/etc/mysql/mysql.conf 中获取信息。
Host '' is not allowed to connect to this MySQL server
Host is not allowed to connect to this MySQL server解决方法-CSDN博客
修改root用户允许远程访问后如果还是无法链接记得重新启动mysql服务
sudo systemctl restart mysql