通过IP远程连接MySQL服务时不允许连接到这个MySQL服务器

当你在连接Mysql时报这个错误时

is not allowed to connect to this MySQL server,意思是 MySQL 服务器不允许来自 IP 地址的连接。这通常是由于 MySQL 服务器的访问控制列表(ACL)限制了特定主机的连接。

要解决这个问题,你需要授予该主机连接到 MySQL 服务器的权限。以下是具体步骤:

  1. 以具有管理权限的用户身份登录 MySQL 服务器(通常是 root 用户)。
  2. 授予必要的权限 给该主机。你可以通过运行以下 SQL 命令来实现:
c 复制代码
GRANT ALL PRIVILEGES ON *.* TO 'your_username'@'192.168.16.180' IDENTIFIED BY 'your_password';

将 'your_username' 替换为你想要授予权限的用户名,将 'your_password' 替换为该用户的密码。

  1. 刷新权限 以应用更改:
c 复制代码
FLUSH PRIVILEGES;

我这里通过命令行连接到 MySQL 服务器

  1. 输入密码:
    输入密码,如果你的用户没有密码,按回车键。
  2. 验证连接:
    一旦成功连接,你会看到 MySQL 的命令提示符。
c 复制代码
PS D:\> D:\ProgramData\mysql\mysql-5.6.50-winx64\bin.\mysql -u root -p''
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 6
Server version: 5.6.50 MySQL Community Server (GPL)

Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

你就可以在 MySQL 命令提示符下执行 SQL 命令了。(OK就是成功了)

c 复制代码
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'192.168.....' IDENTIFIED BY '';
Query OK, 0 rows affected (0.00 sec)

mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)
相关推荐
Eiceblue2 分钟前
Python读取PDF:文本、图片与文档属性
数据库·python·pdf
码农101号26 分钟前
Linux中shell编程表达式和数组讲解
linux·运维·服务器
是小满满满满吗1 小时前
传输层:udp与tcp协议
linux·服务器·网络
Mintimate2 小时前
云服务器 Linux 手动 DD 安装第三方 Linux 发行版:原理与实战
linux·运维·服务器
gadiaola2 小时前
【计算机网络】第3章:传输层—TCP 拥塞控制
网络·网络协议·tcp/ip·计算机网络
RussellFans2 小时前
Linux 环境配置
linux·运维·服务器
网硕互联的小客服2 小时前
503 Service Unavailable:服务器暂时无法处理请求,可能是超载或维护中如何处理?
服务器·git·github
在未来等你2 小时前
SQL进阶之旅 Day 21:临时表与内存表应用
sql·mysql·postgresql·database·temporary-table·memory-table·sql-optimization
高冷的肌肉码喽3 小时前
Linux-进程间的通信
linux·运维·服务器
敖云岚3 小时前
【Redis】分布式锁的介绍与演进之路
数据库·redis·分布式