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服务

sudo systemctl restart mysql

3 大功告成

相关推荐

最近更新

  1. TCP协议是安全的吗?

    2024-01-12 16:36:02       18 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2024-01-12 16:36:02       19 阅读
  3. 【Python教程】压缩PDF文件大小

    2024-01-12 16:36:02       18 阅读
  4. 通过文章id递归查询所有评论(xml)

    2024-01-12 16:36:02       20 阅读

热门阅读

  1. 游戏服务器开发知识付费时代到来了

    2024-01-12 16:36:02       40 阅读
  2. 【mysql】有关mysql查询隐式类型转换的问题

    2024-01-12 16:36:02       34 阅读
  3. LinkedList和ArrayList

    2024-01-12 16:36:02       35 阅读
  4. git远程仓库配置

    2024-01-12 16:36:02       43 阅读
  5. openssl3.2 - 官方demo学习 - cipher - aesccm.c

    2024-01-12 16:36:02       28 阅读
  6. 常见的传感器技术汇总简介

    2024-01-12 16:36:02       38 阅读
  7. sdbusplus:method同步调用通用函数

    2024-01-12 16:36:02       29 阅读