ubuntu 服务器中mysql的安装与连接

1.mysql的安装与初始化

复制代码
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';

2.mysql 进行远程连接的时候报错记录

2.1.1 报错信息

2013 - Lost connection to MySQL server at 'handshake: reading initial communication packet', system error: 11

2.1.2 解决方案

修改配置文件配置允许远程连接

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 中获取信息。

2.2.1 报错信息

Host '' is not allowed to connect to this MySQL server

2.2.2 解决方案

Host is not allowed to connect to this MySQL server解决方法-CSDN博客

修改root用户允许远程访问后如果还是无法链接记得重新启动mysql服务

bash 复制代码
sudo systemctl restart mysql

3 大功告成

相关推荐
ruleslol3 分钟前
MySQL 工具使用指南
mysql
天空之外1366 分钟前
生成一个带 IP 的自签证书、制作Http证书
linux·运维·服务器
爱学java的ptt8 分钟前
mysql的存储引擎
数据库·mysql
希赛网20 分钟前
华为认证HCIP数通备考资源、模拟练习题库哪里下载?
服务器·网络工程师·华为认证·hcip
龘龍龙23 分钟前
Python基础学习(十一)
python·学习·mysql
恒创科技HK24 分钟前
2026年香港服务器走CN2线路具有哪些优势?
运维·服务器
释怀不想释怀32 分钟前
linux常见安装(JDK,mysql,nginx)
linux·运维·服务器
杰克崔35 分钟前
do_exit的hungtask问题及coredump的实验及原理分析一
linux·运维·服务器·车载系统
pengdott41 分钟前
Linux进程数据结构与组织方式深度解析
linux·运维·服务器
不屈的铝合金1 小时前
SQL 语言概述与数据库核心前置配置了解
数据库·sql·mysql·约束·sql 语句分类·字符集配置·校对规则