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 大功告成

相关推荐
麦聪聊数据11 小时前
MySQL 性能调优:从EXPLAIN到JSON索引优化
数据库·sql·mysql·安全·json
lalala_lulu11 小时前
MySQL中InnoDB支持的四种事务隔离级别名称,以及逐级之间的区别?(超详细版)
数据库·mysql
星辰烈龙12 小时前
黑马程序员JavaSE基础加强d5
服务器·网络·php
CV工程师的自我修养12 小时前
你的SQL为什么慢?看懂MySQL EXPLAIN执行计划,快速定位性能瓶颈
数据库·mysql
浩子智控12 小时前
分区操作系统、容器化、虚拟机的概念
服务器·系统安全
小宇的天下12 小时前
Calibre 3Dstack --每日一个命令day7【Centers】(3-7)
java·服务器·数据库
济61712 小时前
linux(第九期)--交叉编译器-- Ubuntu20.04
linux·运维·服务器
zxdzxdzzxd12 小时前
Tailscale Linux 登录指南
linux·运维·服务器
y_想不到名字12 小时前
MySQL windows版本免安装
数据库·mysql
萧曵 丶12 小时前
MySQL 事务隔离级别及实际业务问题详解
数据库·mysql